开发者

File content upload using JSON

I am attempting to upload a file from the browser to a Spring 3.0 MVC application (hosted in Glassfish). The intent is to send the file content through a JSON request.

Attempting to read the file using JavaScript and then placing the file content in a JSON request does not seem advisable as the file content may be large and consume memory on the browser.

Next I attempted using the mootools uploadManager. The documentation and demos deal only with a php server. There is de-coding of the file contents by the php script that handles the upload. So to use mootools uploadManager, I would have to simulate the de-coding (contained in the php script) in my Spring MVC controller. Since this isn't going to be straight forward, I am wondering if 开发者_StackOverflowthere are other elegant solutions to this issue (after reading this and this).

TIA, Vijay


I actually think it would be pretty straight forward to do it in the Spring controller...

  1. simply treat it as any other file upload
  2. then read the file contents and run it through Jackson (or the JSON lib of your choice)

[edit: deleted RestTemplate reference as it requires URI to json, not a file]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜