3

借助 R 包的ftpUpload()功能RCurl,我可以在 FTP 服务器上上传文件。但是如何从 R 在 FTP 服务器上创建一个新文件夹?以及如何删除文件或文件夹?

4

4 回答 4

3

它对我有用,但正确的引用命令是 DELE,而不是 DELETE!这里是命令列表http://www.nsftools.com/tips/RawFTP.htm

所以试试:

curlPerform(url="ftp://xxx.xxx.xxx.xxx/", quote="DELE file.txt", userpwd = "user:pass")
于 2014-10-30T21:31:34.197 回答
3

In order to create a new folder, you can simply include the full path when you upload a file, and enable the ftp.create.missing.dirs option:

.opts <- list(ftp.create.missing.dirs=TRUE)
user <- "yourlogin"
pwd <- "yourpassword"

RCurl::ftpUpload(what = "filename.txt", to = "ftp://yourserver.com:21/newFolder/filename.txt", userpwd = paste(user, pwd, sep = ":"), .opts = opts)
于 2016-04-08T10:42:05.153 回答
1

尝试使用 curlPerform 发送报价命令。尝试这样的删除。您可能需要查找实际的 ftp 命令来创建目录和删除文件。

curlPerform(url="ftp://xxx.xxx.xxx.xxx/", quote="DELETE file.txt", userpwd = "user:pass")
于 2014-01-06T16:29:24.000 回答
0

要创建文件夹,请使用 curlPerform("ftphost",quote="MKD foldername",userpwd="user:pass")。要删除文件,请使用 curlPerform("ftphost",quote="DELETE filename",userpwd="user:pass")。根据 FTP 服务器,您可能必须使用 mkdir 而不是 MKD 和 del 或 DELE 而不是 DELETE。这取决于服务器。

于 2019-01-16T19:45:19.703 回答