archiloque-rest-client:提交文件时将内容类型更改为多部分/相关
使用 http://github.com/archiloque/rest-client
使用此行发布文件时, 默认情况下,内容类型设置为
Content-Type: multipart/form-data; boundary=301405
标头中的内容。
RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb')
我尝试了这个,它仍然设置标头 multipart/form-data。
RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb'), :content_type => 'multipart/related'
有人尝试过设置多部分/相关吗?
Using
http://github.com/archiloque/rest-client
When posting a file using this line, the content type is set as
Content-Type: multipart/form-data; boundary=301405
in the header, by default.
RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb')
I tried this and it still sets the header multipart/form-data.
RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb'), :content_type => 'multipart/related'
Has anybody tried setting multipart/related?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者您可以使用相当新的 multipart_body gem:
http://steve.dynedge.co.uk/2010/09/19/multipart-body-a-gem-for-working-with-multipart-data/
Or you can use rather new-ish multipart_body gem:
http://steve.dynedge.co.uk/2010/09/19/multipart-body-a-gem-for-working-with-multipart-data/
好的。我找不到更好的替代方案,因此最终使用了以下应用程序。
它基于这里的代码。
http://stanislavvitvitskiy.blogspot.com/2008/12/multipart -post-in-ruby.html
用法:
注意: 此代码尚未准备好用于生产。它只是功能性的。
---------------- multipart.rb -------------
Ok. I could not find a better alternative, so ended up with the following app.
It is based on this code here.
http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
Usage:
Note: This code is not production ready. It is just functional.
---------------- multipart.rb -------------