我正在尝试将图片上传到Firebase。
...
if(image != null){
storageRef.child("images").child(getUniqueName()).putBytes(compressImage(image, c.getContentResolver()))
...
和compressImage方法:
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;
}
日志中的“图像大小”为81KB,即smaller than 1MB。任何人都可以建议我为什么会得到这些例外?
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)
和
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)
编辑: 奇怪的是文件确实显示在控制台的Firebase存储中。