通过httpmultipart将图像发送到服务器

时间:2011-09-21 10:12:33

标签: android image

我正在创建一个Android应用程序,我将通过xml将图像从库发送到服务器。任何类型的帮助将不胜感激... hanks

1 个答案:

答案 0 :(得分:1)

这是我在我的应用程序中处理它的方式:

// bitmap is your Bitmap object
ByteArrayOutputStream stream = new ByteArrayOutputStream();
// The next line should be adjust to use the format and compression you want.
bitmap.compress(CompressFormat.PNG, 0, stream);           
byte[] byteArr = stream.toByteArray();
// The next line would be where you write the byte array to your xml structure:
myXml += Base64.encodeBase64String( byteArr ); 

在我的应用程序中,byte []在创建xml结构之前作为blob保存到db。所以这段代码并不是我正在做的。但它应该给你这个想法。