Search code examples
rgetftphttr

R httr GET request - connection time-out


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!


Solution

  • 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))