tags:

views:

136

answers:

1

Hello there, i'm creating an activity which needs to upload an image to a webservice using their api.

I found that if i use UrlEncodedFormEntity and send the image data through that. the webservice doesn't receive that. ( at least it will not be able to read that .)

In fact if i add some vars to send with the image data ( like name of the file, filesize ) they can be read from the webservice but the image data still doesn't appear if i try to read it serverside.

Right now i'm using UrlEncodedFormEntity with BasicNameValuePair as container for my data.

+1  A: 

Hello,

May be it will help you. Ive used the same functionality, but the web service was developed by me)) Ive post the image using the following:

  1. I get the particular Bitmap icon and compress it in byte array like this

    ByteArrayOutputStream out = new ByteArrayOutputStream(10240); icon.compress(CompressFormat.PNG, 100, out);

  2. Then create HttpPost and set the the entity.

    httpPostInstance.setEntity(new ByteArrayEntity(out.toByteArray()));

  3. Check the "Content-type" header. You must properly set it to whatever your service expect.

ponkin