Android: How to send a picture through a service - android

I wonder how is it possible to send a picture.
I am using json to send data and store to database.
But how do I handle a picture?
How do I send it using json?

Look at this:
How to send an image using json to server in iPhone?
Have a look here, shows how to use HTTP with Java:
http://www.java-samples.com/java/POST-toHTTPS-url-free-java-sample-program.htm

Never send bytes, encode it with base64 and compressing does not really help.

Related

Is it possible to send array of image through volley

Is is possible to send array of images using volley library in android.
e.g
param.put("images", arrayOfImages);
Please response as soon as possible.
Yes you can convert the images in base64 strings and send that array of strings using
param.put("images", arrayOfImages);

Getting image url from json is better or using an encoded image within json?

I have a json from server in which the image urls are send from server but i want to know if i ask my php developer person to send encoded image in json would be a better approch or the former one ?
I want to load the images in listview after that.
Thanks in Advance.
getting url will be better and clean approach.it will make your response compact and image url can be loaded any time you want where if you transmit encoded image it has to be transmitted in network even if you dont want to display at the time.

Send image via json in android

Hi I am working with android.I want to send an image from server to android and I had done it with sending url from server.How can I send an image from server to android app via json?? is it possible??
It is possible if you can convert your image at your server to a Base64 encoding string. Then you can send the string to your app via JSON.
You can use Apache Common IOUtils:
Base64.encode(FileUtils.readFileToByteArray(imageFile));
On your app you can convert the string to image, example in this link
How to convert a Base64 string into a BitMap image to show it in a ImageView?
Hope that helps
It is possible to send binary data within Json but you have to escape the binary data (UTF-8 encoding and use Base64.) This will increase the data size. Why not just include the path in JSON and fetch/load it?

Receive an image from server using webservice

I have coded an app in Android which any process get data from MySQL by webservice. Now I want to receive an Image from server but I don't know what should I do? I read some topic and came to know that it should be using MTOM (I'm using apache axis2 to deploy ws) but I can't execute it successfully. Someone please give me the solution, if you can give me the demo, it would be very helpful for me. Thanks a lot!
1) First convert your image into a byte array, then encode it into a base64 string and pass this data to the server, save as a BLOB type. (Results in huge space requirements)
2)Save the image on the SDCard, ftp it to your server, assign an id to the image for future reference ( This method is more fast, relevant in lazy load of list view)
Please search for AQuery that will help you to implement what you want neatly....mere 4 lines of code.

Removing special characters in Json while sending to server

hi after computing im getting json as below
{"xxxx":"{\"value\":\"http:\\\/\\\/blaze.mobiclay.net\\\/action\\\/qzproject\\\/feed\\\/20111015\\\/getfeedurl?feedID=702\",\"type\":\"RSS\"}","yyyy":"{\"value\":\"chg\",\"type\":\"String\"}","zzzz (mins)":"{\"value\":\"3\",\"type\":\"String\"}",
but i need it as below when i need to send it to server
{"xxxx":{"type":"RSS","value":""},"zzzz (mins)":{"type":"String","value":""},"yyyy":{"type":"String","value":""}}
I think this is you are looking for:-)
encode
and decode

Categories

Resources