Search code examples
rrcurl

RCurl::ftpUpload() unspecified error: "Error in function (type, msg, asError = TRUE) : "


I am getting an odd, empty error when trying to use RCurl::ftpUpload():

RCurl::ftpUpload(what = "test.txt",
                 asText = FALSE,
                 to = "sftp://myserver.com/uploads/test.txt",
                 port =2222,
                 userpwd = "user:pass",
                 connecttimeout = 30)

Error in function (type, msg, asError = TRUE) :

I have checked that I can make a connection to the server on that port (ie that it isn't firewalled) and I can, so I don't think that is the issue.

I'm not sure how to proceed since there isn't any actual error information.

It does look like the sftp protocol is available:

RCurl::curlVersion()$protocols
[1] "dict" "file" "ftp" "ftps" "gopher" "http" "https" "imap" "imaps" "ldap" "ldaps" "pop3" "pop3s" "rtmp" "rtsp" "scp" "sftp" "smb" "smbs" "smtp" "smtps" "telnet" "tftp"

Solution

  • Adding ssl arguments to avoid verification should do the trick:

    RCurl::ftpUpload(what = "test.txt",
                     asText = FALSE,
                     to = "sftp://myserver.com/uploads/test.txt",
                     port =2222,
                     userpwd = "user:pass",
                     connecttimeout = 30,
                     ssl.verifypeer = FALSE, 
                     ssl.verifyhost = FALSE)