How to upload multiple images one by one and get results
nvhaiwork opened this issue · 4 comments
I want to upload more than 1 images using loop and MediaManager.get().upload.callback()...
the compile the results in to one but I cant coz callback is asynchronous call, is there any way to make upload with the callback as synchronous call?
Hi,
For synchronous uploading, please use something like this:
Map params = ObjectUtils.asMap(
"public_id", "my_folder/my_sub_folder/my_dog",
"overwrite", true,
"notification_url", "http://mysite/notify_endpoint",
"resource_type", "video"
);
Map uploadResult = cloudinary.uploader().upload(new File("dog.mp4"), params);
Please let me know if it works for you.
Cheers
Hi,
For synchronous uploading, please use something like this:
Map params = ObjectUtils.asMap( "public_id", "my_folder/my_sub_folder/my_dog", "overwrite", true, "notification_url", "http://mysite/notify_endpoint", "resource_type", "video" ); Map uploadResult = cloudinary.uploader().upload(new File("dog.mp4"), params);
Please let me know if it works for you.
Cheers
Thks for you reply but I cant use your code, let me explain:
My code currently using exactly what you recommend above, but with Android Q we cant use
new File("dog.mp4")
due to "scoped external storage access"
"Note: Apps that use scoped storage don't have direct kernel access to paths like /sdcard/DCIM/IMG1024.JPG."
So I have to use
cloudinary.uploader().upload(Uri.parse("uriPath")
but there was a excetions: "java.lang.RuntimeException: Missing required parameter - file"
After that I tried to use
MediaManager.get().upload(Uri.parse("uriPath")
=> everything works as expected but I cant make a synchronous with the callback.
Can you give me a way to work upload with call back in Android Q??
Hi,
Please try this code:
InputStream is = context.getContentResolver().openInputStream(Uri.parse("uriPath"));
cloudinary.uploader().upload(is, options);
Please let me know if it works for you.
InputStream is = context.getContentResolver().openInputStream(Uri.parse("uriPath"));
Works now.
Thanks for your help !!!