I am working on Google Contacts API and I received all data and sending as string to JSON (javascript) but when I get an image from contacts I can receive image. How can I send it to JSON? How can send the image file to a URL? (Can I use signpost?)
if (photoLink.getEtag() != null) {
GDataRequest request = myService.createLinkQueryRequest(photoLink);
request.execute();
// No Authentication header information
InputStream stream = request.getResponseStream();
Image image= ImageIO.read(stream);
}
If you're trying to send the actual image encoded as data using JSON, you can just send an HTML
img
tag with thesrc
attribute containing the encoded image data, like so:Browser Support List (Includes Android Browser & iOS Safari:
http://en.wikipedia.org/wiki/Data_URI_scheme#Web_browser_support
You should simply use a servlet for sending images and just send some url variable in JSON. (like
?pic_id=034enifuwbf0329
.You could use inline image, but that would fail miserably on certain IE versions, while the other solution is browser-agnostic.