bug in android image upload from byte array
Hi
My usecase: I was trying to upload an image. Before uploading I'm ask user to manually crop the file. So after cropping I'm only having Bitmap and byte array (no uri or file path). But not able to upload it directly to cloudinary. Getting EmptyByteArrayException (I'm having byte array of around 11000 bytes).
My analysis: I'm calling MediaManager class's upload method. It is working when I'm using uri request. But for byte array it is giving error. As in your PayloadFactory you are calling parsed.getHost() which will be empty in case of byte array payload.
package com.cloudinary.android.payload;
public class PayloadFactory {
private static final String TAG = PayloadFactory.class.getSimpleName();
/**
* Constructs the payload extracted from the uri.
*
* @param uri Uri that contains the payload data and type
* @return The constructed payload
*/
public static Payload fromUri(String uri) {
Uri parsed = Uri.parse(uri);
String scheme = parsed.getScheme();
// invalid payload
if (scheme == null) {
return null;
}
Payload payload;
switch (scheme) {
case ByteArrayPayload.URI_KEY:
payload = new ByteArrayPayload();
break;
case FilePayload.URI_KEY:
payload = new FilePayload();
break;
case LocalUriPayload.URI_KEY:
payload = new LocalUriPayload();
break;
case ResourcePayload.URI_KEY:
payload = new ResourcePayload();
break;
default:
return null;
}
payload.loadData(parsed.getHost());
return payload;
}
}
Please help urgently as it is a blocker for me.
-
Hi Sankalp,
Thanks for notifying us about this issue.
I will update you as soon as we release a fix for that.
Best,
Yakir
0 -
Hi
Wanted to let you know that we have released the relevant fix for this.
Let us know if its okay on your end?
0
Post is closed for comments.
Comments
2 comments