Sending BLOBs in a JSON service,... how?

Posted by Marten Sytema on Stack Overflow See other posts from Stack Overflow or by Marten Sytema
Published on 2011-01-16T19:39:03Z Indexed on 2011/01/16 19:53 UTC
Read the original article Hit count: 282

Filed under:
|
|
|

Hello

I have a webservice (ie. servlet) implemented in Java. It gets some data from a MySQL table, with one column being of type BLOB (an image), and some other columns are just plain text. Normally I would store the file outside the database with a pointer to it in the database, but due to circumstance I now have to use this BLOB column...

What is the proper way to send this? How to encode the image in a JSONObject, and how to parse (and RENDER!) it on the otherside ?

I want to use JSONP, to avoid having to proxy it through the consumer's webserver.

So that the consumer can just put in a tag pointing to the webservice, calling a callback.

Any thoughts how to handle images in this situation? Also thoughts on performance etc. are interesting!

© Stack Overflow or respective owner

Related posts about JSON

Related posts about servlets