gpt4 book ai didi

android - 通过httpmultipart向服务器发送图片

转载 作者:行者123 更新时间:2023-11-30 04:32:15 25 4
gpt4 key购买 nike

我正在制作一个 android 应用程序,我在其中通过 xml 将图像从图库发送到服务器..任何类型的帮助将不胜感激......谢谢

最佳答案

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

// 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 保存到数据库中。所以这段代码并不是我正在做的。但它应该给你想法。

关于android - 通过httpmultipart向服务器发送图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7498086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com