Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a folder and deleting on a FTP server with RCurl

Tags:

r

ftp

rcurl

With the ftpUpload() function of the RCurl package for R, I am able to upload a file on a FTP server. But how to create a new folder on the FTP server from R ? And how to delete a file or a folder ?

like image 445
Stéphane Laurent Avatar asked Dec 12 '25 18:12

Stéphane Laurent


2 Answers

It works for me, but the correct quote command is DELE, not DELETE! Here a list of commands http://www.nsftools.com/tips/RawFTP.htm

So try:

curlPerform(url="ftp://xxx.xxx.xxx.xxx/", quote="DELE file.txt", userpwd = "user:pass")
like image 119
Ruggero Valentinotti Avatar answered Dec 15 '25 11:12

Ruggero Valentinotti


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)
like image 24
giocomai Avatar answered Dec 15 '25 11:12

giocomai