Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R httr GET request - connection time-out

Tags:

r

get

ftp

httr

I am trying to download programmatically files like this from an ftp. The home page provides openly username ("fire") and password ("burnt") and I can download the files no problem from browser.

When I try to do the same in R using httr::GET()

library("httr")
GET(url = "ftp://fuoco.geog.umd.edu/gfed4/monthly/GFED4.0_MQ_200301_BA.hdf",
    authenticate(user = "fire", password = "burnt"),
    write_disk(file.path(tempdir(), "GFED4.0_MQ_200301_BA.hdf"),
               overwrite = TRUE))

I get the following error

Error in curl::curl_fetch_disk(url, x$path, handle = handle) : 
  Timeout was reached: Connection time-out

I would greatly appreciate any idea to fix this problem, many thanks!

like image 235
Claudia Avatar asked Oct 21 '25 05:10

Claudia


1 Answers

The problem seems to be that FTP isn't supported by library(httr):

Please see this, or more recent this.

I'd give library(RCurl) a go instead:

library(RCurl)
url <- "ftp://fuoco.geog.umd.edu/gfed4/monthly/GFED4.0_MQ_200301_BA.hdf"
content <- getBinaryURL(url, userpwd = "fire:burnt", ftp.use.epsv = FALSE)
writeBin(content, con = basename(url))
like image 116
ismirsehregal Avatar answered Oct 23 '25 19:10

ismirsehregal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!