如何在Rails中通过JSON接口上传文件 [英] How to upload file via the JSON interface in Rails
本文介绍了如何在Rails中通过JSON接口上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Rails中有一个Web服务,该服务除其他外应向客户端提供文件上传功能.所有客户端都使用JSON与Web服务进行通信.我使用Paperclip插件进行上传管理.
I have a web service in Rails which among all else should provide file upload functionality to the clients. The clients all use JSON to talk to the webservice. I use the Paperclip plugin for upload management.
问题是我不知道如何通过JSON上传文件.所有这些都可以在Web Formular中使用,但是我找不到有关如何构造JSON请求以将文件发送到服务器的信息.有人可以帮忙吗?
The problem is I do not know how to upload a file via JSON. All works in the web formular, but I cannot find information on how to consctruct my JSON Request to send files to the server. Can somebody help out?
关于, 天使卡法佐夫
推荐答案
我还没有尝试过,但这看起来很有希望:
I didn't try this yet, but this looks promising: