简体   繁体   English

R ftpUplad 错误:无法打开连接

[英]R ftpUplad error: cannot open the connection

I am trying to upload a data.frame called 'ftp_test' via ftpUpload command我正在尝试通过 ftpUpload 命令上传名为“ftp_test”的 data.frame

library(RCurl)
ftpUpload("Localfile.html", "ftp://User:Password@FTPServer/Destination.html")

and am getting an error:并且出现错误:

Error in file(what, "rb") : cannot open the connection In addition: Warning message: In file(what, "rb") : cannot open file 'ftp_test': No such file or directory文件错误(什么,“rb”):无法打开连接另外:警告消息:在文件(什么,“rb”)中:无法打开文件“ftp_test”:没有这样的文件或目录

Could anyone tell me what is the issue here?谁能告诉我这里有什么问题? Can I actually use data.frame and upload from r global environment ?我真的可以使用 data.frame 并从 r 全局环境上传吗?

If I can't use the data.frame is there any workaround?如果我不能使用 data.frame 有什么解决方法吗?

Many thanks,非常感谢,

Artur阿图尔

You problem is, that you are trying to send an R object with an file transfer protocol.您的问题是,您正在尝试使用文件传输协议发送 R 对象。 Since you are saving it there, you have to tell how to save it.既然你把它保存在那里,你必须告诉如何保存它。 A workaround is to save it as a file, upload it and then delete it on your local afterwards.解决方法是将其另存为文件,上传,然后在本地删除。 Also saving as R.History is fine, but you need to transfer the R object to a file in some way.保存为 R.History 也可以,但您需要以某种方式将 R 对象传输到文件中。 This example is used with an open ftp sever (uploads get deleted immediately, but you can try if it works)此示例与打开的 ftp 服务器一起使用(上传会立即删除,但您可以尝试是否有效)

filename="test.csv"
write.csv(df, file=filename)
#use your path to the csv file here instead of ".~/test.csv", you can check with getwd()
ftpUpload("~/test.csv", paste("ftp://speedtest.tele2.net/upload/",filename, sep=""))

file.remove(filename)

Also make sure your server is running.还要确保您的服务器正在运行。 You can try your code with the open ftp server.您可以使用开放的 ftp 服务器尝试您的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM