通过JSON / XML发送二进制数据(Rails)的REST风格的终点? [英] Sending binary data to (Rails) RESTful endpoint via JSON/XML?

查看:216
本文介绍了通过JSON / XML发送二进制数据(Rails)的REST风格的终点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在组建一个基于Rails的Web应用程序,这将只会和通过JSON和XML接收数据。然而,一些要求包含上载二进制数据(图像)的能力。

I am currently putting together a rails-based web application which will only serve and receive data via json and xml. However, some requirements contain the ability to upload binary data (images).

现在我的理解JSON是不完全意味着该...但你怎么对付一般在这两个入口点到你的应用程序接收二进制文件/数据的问题?

Now to my understanding JSON is not entirely meant for that... but how do you in general tackle the problem of receiving binary files/data over those two entrypoints to your application?

推荐答案

我建议在类似Base64编码的二进制数据。这将使得它的安全XML或JSON格式使用。

I suggest encoding the binary data in something like base64. This would make it safe to use in XML or JSON format.

http://en.wikipedia.org/wiki/Base64

这篇关于通过JSON / XML发送二进制数据(Rails)的REST风格的终点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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