Roy James Schumacher
Roy James Schumacher

Reputation: 646

Sending pictures from android device to server

im trying to send a picture from a android device to a server and was wondering if it was possible to send the picture information in a xml file and rebuild it on the server?

Upvotes: 1

Views: 1580

Answers (3)

Mohammad Ersan
Mohammad Ersan

Reputation: 12444

you can user Base64to send your image as text, so you can put in xml file

Upvotes: 0

Maurício Linhares
Maurício Linhares

Reputation: 40313

Yes, there is, you just have to use Base64 to encode and decode the file stream. To encode you'll use the android.util.Base64 class and at the server side (if you're also using Java) you can use the commons-codec Base64 class.

The idea would be build the xml file as with whatever tool you would like to:

<image>
  <user>username</user>
  <other-property>property</other-property>
  <data><-- here you'll add your base64 encoded image as a string -->
</image>

Once you do this, just upload the XML file itself to your server and parse the XML file in there.

Upvotes: 1

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72301

You should use a MultiPartPost. This SO answer is exactly what you are looking for.

Upvotes: 0

Related Questions