我无法将curl命令转换为ruby rest-client
curl 'http://localhost:8080/../attachments' -H "Content-Type: multipart/form-data" -H "CMD-Authorization: xxxx" -X POST -F attachment='{"_description":"this is test";type=application/json' -F file=@/root/Desktop/rest/saturn.bin
主要问题涉及" type = application / json "以附件的形式。
我的代码是:
require 'base64'
require 'rest-client'
require 'json'
....
file1=File.new('/root/Desktop/rest/saturn.bin','rb')
response =RestClient.post("#{uri}",
{
:attachment=>'{"_description":"this is test";"type"=>"application/json"}',
:file=>file1,
},{:cmd_authorization=>"#{@session_id}"})`
我尝试了其他代码组合添加,例如:content_type =>" application / json"在标题中失败。感谢您的支持。