multipart POST with Chef http_request resource

2019-08-09 04:50发布

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条回答
劳资没心,怎么记你
2楼-- · 2019-08-09 05:48

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.

查看更多
登录 后发表回答