使用R将CSV文件上传到REST API [英] Upload csv file to REST API with R

查看:116
本文介绍了使用R将CSV文件上传到REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个csv文件上传到REST API. 可通过

I want to upload a csv file to a REST API. The API is accessible via an URL like

http://sampledomain.com/api/data/?key=xxx

提供的示例curl调用如下:

A provided sample curl call looks as following:

 curl --form "file=@my_data.zip" \
     "http://sampledomain.com/api/data/?key=xxx"

如何将此调用转换为R? 我听说过RCurl软件包,但无法弄清楚在这种情况下如何使用它.

How can I translate this call into R? I heard of the RCurl package, but can´t figure out how to use it in this case.

致谢

推荐答案

我不确定RCurl是否会处理它,如从

I am not sure RCurl will handle it as you can see from the limit on the first page.

限制人们尚未完全控制a的内容 POST形式,例如指定文件,内容类型.错误处理用途 目前只有一个全局变量.

Limitations One doesn't yet have full control over the contents of a POST form such as specifying files, content type. Error handling uses a single global variable at present.

但是,Hadley的另一个软件包可能会解决您的问题 httr

However, another package from Hadley that might solve your problem httr

POST("http://sampledomain.com/api/data/?key=xxx", body = list(y = upload_file(system.file("my_data.zip"))))

这篇关于使用R将CSV文件上传到REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆