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)})
精彩评论