Answer the question
In order to leave comments, you need to log in
Android cut Base64 string?
Comrades, tell me what is the ambush?
Actually, you need to post json to the server, one of the fields of which is a photo in Base64.
The problem is that I'm only getting part of the picture in a Base64 string.
Image->Base64
public static String encodeTobase64(Bitmap image) {
Bitmap immagex = image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immagex.compress(Bitmap.CompressFormat.PNG, 100, baos);
profileImage.setImageBitmap(Bitmap.createScaledBitmap(immagex, 120, 120, false));
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(profileImage, Base64.DEFAULT);
return imageEncoded;
}
Answer the question
In order to leave comments, you need to log in
There is a limit on the length of a constant string - 64kb, if my memory serves me right.
The post needs to send a multipart entity, not json.
And so the conversion should work correctly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question