Using RCurl with SFTP

假装没事ソ 提交于 2019-12-12 10:59:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!