how to upload image in base64 on server

前端 未结 1 870
执笔经年
执笔经年 2021-01-05 13:00

i have a problem, i am uploading image on server but it is not. i have convert image in base64 and get through json. but json is not properly clos

相关标签:
1条回答
  • 2021-01-05 13:14
    String encodedImageData =getEncoded64ImageStringFromBitmap(your bitmap);
    
    public String getEncoded64ImageStringFromBitmap(Bitmap bitmap) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(CompressFormat.JPEG, 70, stream);
        byte[] byteFormat = stream.toByteArray();
        // get the base 64 string
        String imgString = Base64.encodeToString(byteFormat, Base64.NO_WRAP);
    
        return imgString;
    }
    
    0 讨论(0)
提交回复
热议问题