gpt4 book ai didi

android - 如何将大型编码的base64图像字符串从Android发送到Mysql

转载 作者:行者123 更新时间:2023-11-29 10:40:20 25 4
gpt4 key购买 nike

如何将大型编码图像 base64 字符串从 android 发送到服务器

friend 们大家好,

 By default String value within 8000 characters is uploading to server.

But Encoded Image base64 String length is more than 8000 characters.

超过超过8000个字符未从android上传到mysql数据库。

请给我一个解决方案..!

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == RESULT_LOAD_IMAGE) {
// Make sure the request was successful
// Log.d("Vicky","I'm out.");

display(requestCode,resultCode,data);

}
}

public void display(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri selectedImageUri = data.getData();
Bitmap selectedImageBitmap = null;
try {
selectedImageBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), selectedImageUri);
} catch (IOException e) {
e.printStackTrace();
}
selectedImage.setImageBitmap(selectedImageBitmap);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
selectedImageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] byteArrayImage = byteArrayOutputStream.toByteArray();
encodedImage = Base64.encodeToString(byteArrayImage, Base64.DEFAULT);}}

最佳答案

只需检查您的数据库结构图像字段是否具有如下数据类型 longblob

like this

关于android - 如何将大型编码的base64图像字符串从Android发送到Mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45611351/

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