从Android设备到服务器发送图片 [英] Sending pictures from android device to server

查看:99
本文介绍了从Android设备到服务器发送图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从Android设备发送图片到服务器,并想知道是否有可能在发送一个XML文件中的图片信息,并重建它在服务器上?

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?

推荐答案

对了,还有,你只需要使用Base64编码为en code和德code文件流。要带code你会使用 android.util.Base64 类,并在服务器端(如果您还使用Java的),你可以使用的 commons- codeC 的Base64类。

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.

这个想法是建立在XML文件与任何工具,你想:

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>

一旦你做到这一点,只需上传XML文件本身到您的服务器和解析XML文件中出现。

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

这篇关于从Android设备到服务器发送图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆