Skip to content Skip to sidebar Skip to footer

MultiPartEntity Along With Plain Text In Android

I am trying to send MultiPartEntity to the server to upload an image. I have to send data to the server with a MultiPartEntity, The following is a sample request. { 'user': {

Solution 1:

There are two way to achieve your goal.

1)Using JSON

Android Side:- First thing is JSON format can support only string data, so you can add only string data. If you want to add image in JSON format so you have to convert Image to String. Image into bytearray

Server Side:- Decode byte string and convert in Image.

2)Using NameValuePair

Android Side:- Used NameValuePair instead of JSON, for this way follow link which HardikJoshi given in comment (Link)

Server Side:- Change server code JSON to NameValuePair.

I suggest Second Way is easy to implement & understand..


Post a Comment for "MultiPartEntity Along With Plain Text In Android"