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

时间:2022-11-13 13:37:19

How to send the Large encoded Image base64 string to server from android.

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

HI Friends,

嗨朋友们,

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

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

More than 8000 characters is not uploading from android to mysql database.

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

please Give me a solution..!

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

 @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);}}

3 个解决方案

#1


1  

Store the image in a file and save the path of image in your database.

将图像存储在文件中,并将图像路径保存在数据库中。

#2


0  

just check your database structure image field have datatype longblob like below

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

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

#3


0  

Change your data type to VARCHAR. Max lenght of it it's around 65000. You can find more info here

将您的数据类型更改为VARCHAR。它的最大长度是65000左右。你可以在这里找到更多信息

ALTER TABLE tablename MODIFY columnname VARCHAR(65000);

#1


1  

Store the image in a file and save the path of image in your database.

将图像存储在文件中,并将图像路径保存在数据库中。

#2


0  

just check your database structure image field have datatype longblob like below

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

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

#3


0  

Change your data type to VARCHAR. Max lenght of it it's around 65000. You can find more info here

将您的数据类型更改为VARCHAR。它的最大长度是65000左右。你可以在这里找到更多信息

ALTER TABLE tablename MODIFY columnname VARCHAR(65000);