[R] how to know if a file exists on a remote server?

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Nov 30 18:21:04 CET 2010


Neither "file_test" nor "file.exists" address the OP question, since
both of these depend on the filesystem "stat" call, which doesn't work
via arbitrary remote access protocols such as "http".

Baoqiang Cao: The simplest answer is that if you want the file, try
to download it, and deal with any error you get appropriately.

If you have a particular network protocol that supports it (e.g. ftp) or 
if the
server is configured appropriately (e.g. http access to the directory)
you are using, you may have a way to obtain a list of existing files.

Henrique Dallazuanna wrote:
> Take a look on ?file_test
>
> On Tue, Nov 30, 2010 at 2:10 PM, Baoqiang Cao <bqcaomail at gmail.com> wrote:
>   
>> Hi,
>>
>> I'd like to download some data files from a remote server, the problem
>> here is that some of the files actually don't exist, which I don't
>> know before try. Just wondering if a function in R could tell me if a
>> file exists on a remote server? I searched this mailing list and after
>> read severals mails, still clueless.  Any help will be highly
>> appreciated.
>>
>> B.C.
>>
>> ______________________________________________
>>     
>
>
>   
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list