如何使用httparty上传视频文件
嗨,我看过 httparty,但我不知道如何实现,有很多模型文件的示例,但哪些参数可用于上传视频文件
hi I have seen httparty but I don't have a idea to how to implement there are many example of model file but which paramater can be use for upload the video file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
HTTParty 似乎不支持文件上传(至少从 2009 年开始):
Google 群组中有人说不支持:
http://groups.google.com/group/httparty-gem/browse_thread /thread/fe8a3af8c46e7c75
与之相关的开放问题:
https://github.com/jnunemaker/httparty/issues/77
HTTParty does not appear to support file uploads (as least as of 2009):
Google groups where some people say it's not supported:
http://groups.google.com/group/httparty-gem/browse_thread/thread/fe8a3af8c46e7c75
Open Issue concerning it:
https://github.com/jnunemaker/httparty/issues/77
通过使用 RestClient gem,我们可以轻松处理文件上传,但请确保安装了 Rest-client gem。
我还附上了邮递员的示例请求的屏幕截图。
控制器中的代码如下所示,
在此处输入图像描述
By using the RestClient gem we can easily handle the file uploads, but make sure that you install the rest-client gem.
And I have also attached screen shot of example request from postman.
And the code in controller as like below,
enter image description here
这是来自 HTTParty 的多部分示例:
现在,您可以在控制器中访问上传的文件,如下所示:
Here is the multipart example from HTTParty:
Now, you can access the uploaded file in the controller as follows:
HTTMultiParty 通过发布多部分 MIME 文档来支持文件上传。它包装了 HTTParty,因此您可以以相同的方式使用它。对于文件,只需提供一个 File 对象。自述文件中的示例:
HTTMultiParty supports file uploads by posting a multipart MIME document. It wraps HTTParty so you use it in the same way. For the file, just supply a File object. Example from the README: