使用 Paperclip 通过 http 将图像发布请求上传到其他应用程序 [英] Upload image post request over http to other application using Paperclip

查看:46
本文介绍了使用 Paperclip 通过 http 将图像发布请求上传到其他应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用回形针将图像附件上传到我的应用程序.但我想通过法拉第连接将图像发送到另一个应用程序.其他属性已成功发送,但不是附件图像.我不确定我应该怎么做才能实现这一目标.

I am able to upload image attachements using paperclip to my application. But I would like to send the image to another application via faraday connection. Other attributes are successfully sent but not the attachment image. I am not sure what I should do to achieve this.

推荐答案

您需要使用可以创建多部分 Post 请求的 HTTP 库.

You need to use an HTTP library that can create Multipart Post requests.

例如 Typhoeus 可以上传文件:https://github.com/typhoeus/typhoeus#handling-file-uploads.

For example Typhoeus can do file uploads: https://github.com/typhoeus/typhoeus#handling-file-uploads.

还有 Net::HTTP Multipart Post:https://github.com/nicksieger/multipart-发帖

There's also Net::HTTP Multipart Post: https://github.com/nicksieger/multipart-post

最后:https://github.com/jwagener/httmultiparty

阅读这些 gem 的自述文件,它们都使上传文件变得同样容易.我喜欢 Typhoeus,因为它可以执行并行请求.另外两个更简单,但同样有用.

Read the READMEs to any of those gems, they all make it equally easy to do file uploads. I like Typhoeus because it can do parallel requests. The other two are a bit simpler but equally useful.

详细了解什么是多部分表单帖子:

Learn more about what a multipart form post is:

这篇关于使用 Paperclip 通过 http 将图像发布请求上传到其他应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆