multipart POST with Chef http_request resource

≯℡__Kan透↙ 提交于 2019-12-11 10:23:33

问题


Is there a way to do a multipart post with the Chef http_request resource? I have something like the following which posts the file contents, but I need to post form data along with it.

http_request 'post_file_and_form_data' do
  headers ({'Content-Type' => 'multipart/form-data'})
  url "http://myhost:2000/myapp/upload"
  action :post
  message lazy { ::File.read("/somewhere/myFile.yaml") }
end

回答1:


I'm not sure this is supported in the underlying Ruby standard library (Net::HTTP). I've seen most implementations that need this end up using the multipart-post gem. I'd suggest installing that and using it in your recipe, perhaps in a Ruby block.



来源:https://stackoverflow.com/questions/33262830/multipart-post-with-chef-http-request-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!