Sending pictures from android device to server
im trying to send a pictur开发者_如何学编程e 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?
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.
You should use a MultiPartPost. This SO answer is exactly what you are looking for.
you can user Base64
to send your image as text, so you can put in xml file
精彩评论