How to upload a file to a server via FTP using R?

2020-02-09 10:55发布

问题:

How to upload a file to a server via FTP using R?

回答1:

This should work:

library(RCurl)
ftpUpload("Localfile.html", "ftp://User:Password@FTPServer/Destination.html")

Where Localfile.html is the file to be uploaded, User indicates the user name and Password the password to log into the server while FTPServer is a placeholder for the server name and possible path to use while last but not least Destination.html is an example of the name the to be uploaded file gets on the server.



回答2:

Your best bet may be the RCurl package. From the DESCRIPTION:

[...] Additionally, the underlying implementation is robust and extensive, supporting FTP/FTPS/TFTP (uploads and downloads),

Otherwise, rethink your problem. Maybe HTTP POST will do as well. It's not 1986 anymore so you're not required to use ftp.



回答3:

If you can access it from the command line, then you can do:

system("ftp ...") # where ... is the argument list

You could easily wrap this in an R function if you plan on doing it often.



回答4:

This probably isn't the answer you're looking for, but I solve my sharing problems by moving the file to my Public dropbox folder and link to that in my R code.

My two pennies.