开发者

HTTPClient post from string

I'm trying to开发者_运维知识库 integrate Zoho viewer:

clnt = HTTPClient.new
@zoho_link = clnt.post('http://viewer.zoho.com/api/view.do', {:apikey => 'd4a361ce621000000000000', :file => File.new('/home/jon/Desktop/data.csv')})

I already have data in a variable and I want to pass it as a multipart post parameter. How can I make this work without creating a data.csv file?

Thanks!


Use StringIO thusly:

require 'stringio'
clnt = HTTPClient.new
@zoho_link = clnt.post('http://viewer.zoho.com/api/view.do', {:apikey => 'd4a361ce621000000000000', :file => StringIO.new(your_string)})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜