在JSON对象中嵌入文件附件 [英] Embedding a File Attachment in JSON Object

查看:177
本文介绍了在JSON对象中嵌入文件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在JSON对象中嵌入文件附件?我有一个HTML表单,它有几个文本字段输入和一个文件附件。我想发送一个JSON对象包装所有这些表单数据(包括文件附件)到服务器。

有没有Java中的任何特定的库可以做到这一点?您可以给这个解决方案。



谢谢 你想发送文件的实际数据,你可能想要将它编码为base64字符串,并将其发送到 JSON 中 - 参见小提琴编码的例子在javascript:



http://jsfiddle.net/ eliseosoto / JHQnk /

然后你可以在你的服务器端使用任何适合的语言和/或库来做相反的事。


Is it possible to embed a file attachment in a JSON Object. I have a HTML Form, which has several text field inputs and a file attachment. I want to send a JSON Object wrapping all these form data (including the file attachment) to the server.

Are there any particular libraries in Java available to do that? Can you give possible solution for this.

Thanks

解决方案

If you want to send the actual data of the file, you'd probably want to encode it as a base64 string and send that in your JSON - see fiddle for example of encoding it in javascript:

http://jsfiddle.net/eliseosoto/JHQnk/

Then you could do the opposite on your server-side using whatever language and/or libraries are appropriate.

这篇关于在JSON对象中嵌入文件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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