Skip to content
Prev 171910 / 398503 Next

ftp fetch using RCurl?

Hi Stanley.
CHD850 wrote:
Yes, curl can keep connections alive. One can create a curl handle with

  h = getCurlHandle()

and then use this in subsequent, related calls, e.g.

   getURLContent("ftp://....", curl = curl)

Keeping the connection alive is more common in HTTP and can be done
explicitly by specifying

    Connection = "Keep-Alive"

as one of the values for httpheader. But this is for HTTP. For FTP,
I'd have to look up the relevant curl options.

In addition to using a single handle across multiple calls, one
can use the multi-curl interface within RCurl which allows one
to make many asynchronous requests and process them as they reply.
This can often be be faster than the same number of requests done
sequentially.
I would use something like

   content = getURLContent("ftp://...../foo.zip")

   attributes(content) = NULL

   writeBin(content, "/tmp/foo.zip")

and that should be sufficient.

(You have to strip the attributes or writeBin() complains.)