问题
I'm attempting to use the ftpUpload
in the RCurl package for the first time.
The site I'm trying to access uses the sftp protocol. I've made sure to install the version of libcurl that includes the ability to make secure connections.
SFTP is listed among the protocols available to RCurl:
curlVersion()$protocols
[1] "dict" "file" "ftp" "ftps" "gopher"
[6] "http" "https" "imap" "imaps" "ldap"
[11] "pop3" "pop3s" "rtmp" "rtsp" "scp"
[16] "sftp" "smtp" "smtps" "telnet" "tftp"
Yet, when I run the fileUpload
function I get:
ftpUpload(what = "some_file.png",
to = "userid:password@sftp://ec2-some-server-ip.compute-1.amazonaws.com")
Error in function (type, msg, asError = TRUE) :
Couldn't resolve host 'sftp'
I have also tried breaking the userid
and password
out in terms of parameterization, but I get the same response.
Any suggestions would be appreciated.
回答1:
The userid and password need to be after the protocol (thats why you're getting the cannot find host sftp error):
ftpUpload(what = "some_file.png",
to = "sftp://userid:password@ec2-some-server-ip.compute-1.amazonaws.com:22/path/some_file.png")
I also suggest including the port number after the host in case it's not the default and the file path on the server where you want it to go.
来源:https://stackoverflow.com/questions/12268281/using-rcurl-with-sftp