I'm trying to upload an image to Firebase.
...
if(image != null){
storageRef.child("images").child(getUniqueName()).putBytes(compressImage(image, c.getContentResolver()))
...
and compressImage method:
public static byte[] compressImage(Uri data, ContentResolver resolver) {
Bitmap bmpSample;
try {
bmpSample = MediaStore.Images.Media.getBitmap(resolver, data);
ByteArrayOutputStream out = new ByteArrayOutputStream();
bmpSample.compress(Bitmap.CompressFormat.JPEG, 0, out);
byte[] byteArray = out.toByteArray();
Log.d("image size", byteArray.length/1024+"");
return byteArray;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
"image size" in the log is 81KB which is smaller than 1MB. Can anyone suggest why do I get these exceptions?
android.os.TransactionTooLargeException: data parcel size 20173896 bytes
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:5453)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:96)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
and:
D/Error: ERR: stack=java.lang.StackOverflowError: stack size 8MB
at java.lang.reflect.Method.invoke(Native Method)
at com.google.android.gms.internal.zzbqi$zza.zzaF(Unknown Source)
at com.google.android.gms.internal.zzbqi.zzax(Unknown Source)
EDIT: The weird thing is that the files do show in the Firebase Storage in the console.