本文介绍了使用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.

但是,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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 21:24