Best Way to Check if File Exists on Remote Server?

I’ve got a library of image files stored on my server. I’m trying to check if a particular file name image exists (to see if the user has added it to the library). Although I’ve used FolderItems and GetFolderItem in the past for local files, I’ve never tried it with the “remote server” location before now. I can’t seem to find a way to make anything work with those methods. I could post all the coding of the different attempts I’ve made, but suffice it to say that each one of them ended with a Nil Object Exception (never makes it through the if f <> Nil AND f.exists check even though the file name in question does exist).

I have searched the forum here as thoroughly as I could but keep finding references to files existing already on the Hard Drive, Desktop, Special Folders, etc. etc. … all local stuff. I’m whacked out searching … kinda makes me wonder (worry?) why I don’t find much when I do a Forum or Google search on the title of this conversation.

Can anyone point me in the right direction and tell me how you do it? This is one I’m beginning to run short on time for … the reason I’m sitting here working on it this weekend is I’ve got to demonstrate a working prototype of the desktop application this coming week to my largest customer.

Thanks in advance for any help you might provide!
… Don

How do you connect to the remote server? HTTP? FTP? Something else?

Hey Paul, thanks once again for responding. The answer to your question is “HTTP” is the connection means. I have a server (rented space from Rackspace) that I use for maintaining a library of JPEG image files that are the items in question here.

As of late last night though, it looks like I’ve got a solution. I got the idea of using the CURLSMBS plug I own to see if I could query the filename in question to check for existence. By looking at the file size and response code (e.g., ‘404’ indicates missing, etc.) returned, I could easily determine if the file was there or not. All of this could be accomplished with a “peek” at the file header info and no download or other time-intensive actions required.

Turns out the theory was correct but a strange “caching” problem initially got in my way. Christian Schmidt worked with me by email from 3:30 AM yesterday morning until we arrived at a successful coding conclusion late last night. I have found that there are a lot of mighty helpful people around the Xojo community and he, like you, is certainly one of them. The guy redefines “customer service”.

I do find it curious though that in addition to finding absolutely nothing from Googling efforts about the topic matter, no one responded to what I thought was an otherwise “generic” question I posted about this topic. Surely I can’t be in that small a minority of people having the need of checking for file existence on a remote server … obviously, not every file in the digital world exists on a local platform. Or maybe it was just a slow Saturday on the forum … I’m not real sure at this point.

So even though I have an answer now with my CURLSMBS for my immediate need, could you shed some light on what it would have taken to do the task without such a plug? I stand to learn a lot from your answer. In that regard, I’m still clueless.

Thanks again … Don

Use an httpsocket & open the url the the image
You’ll get back response that says you found it or a 404

Thanks, Norman … I kinda figured it had to be something rather easy.

… and do you realize you could have answered that question just as easily from a beach in Costa Rica??? :slight_smile:

well you have to BE there to do that :stuck_out_tongue:
instead I’m here in central alberta where its a balmy -29C :slight_smile: