开发者

HTTPClient post from string

开发者 https://www.devze.com 2023-02-12 19:24 出处:网络
I\'m trying to开发者_运维知识库 integrate Zoho viewer: clnt = HTTPClient.new @zoho_link = clnt.post(\'http://viewer.zoho.com/api/view.do\', {:apikey => \'d4a361ce621000000000000\', :file => Fil

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

精彩评论

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