Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android library: Upload Raw files. #20

Closed
coomar2841 opened this issue May 3, 2015 · 6 comments
Closed

Android library: Upload Raw files. #20

coomar2841 opened this issue May 3, 2015 · 6 comments
Assignees

Comments

@coomar2841
Copy link

How do I upload a raw file to cloudinary using the android SDK? If I use the upload method, which works for images, it saves the file as an image(for a video).

I tried the uploadLargeRaw method, but getting errors.

java.lang.RuntimeException: Missing required parameter - file
at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:101)
at com.cloudinary.Uploader.callApi(Uploader.java:22)
at com.cloudinary.Uploader.uploadLargeRawParts(Uploader.java:116)
at com.cloudinary.Uploader.uploadLargeRaw(Uploader.java:75)
at com.cloudinary.Uploader.uploadLargeRaw(Uploader.java:59)
@tocker
Copy link
Contributor

tocker commented May 4, 2015

Based on your error stack, it looks like you are using older code. Please refresh your code (version as of writing is 1.2.0), and try again.

If you are still experiencing this error, please include the relevant segment of your code together with the error stack.

@coomar2841
Copy link
Author

Ok, I tried 1.2.0, and while trying to upload a mp4 video file, got this error.
This is with upload method.

java.lang.RuntimeException: Invalid image file
at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:104)
at com.cloudinary.Uploader.callApi(Uploader.java:22)
at com.cloudinary.Uploader.upload(Uploader.java:55)
Cloudinary cloudinary = new Cloudinary(ObjectUtils.asMap(
                "cloud_name", "XXXX",
                "api_key", "XXXX",
                "api_secret", "XXXX"));
File toUpload = new File("path to file.mp4");
uploadResult = cloudinary.uploader().upload(toUpload, options);
remoteUrl = uploadResult.get("url").toString();

Also, I get the same error, when I try to upload some random files like mp3, or xls. PDF works though, with this same code, after which I thought I should try with the upload method.

With uploadLargeRaw, it works now for videos. But, the returned url doesn't have the file extension. And, also, there is no preview image. Is there a way that I can upload a video, and also get a generated preview of the same, as it is done for PDF files?

@tocker
Copy link
Contributor

tocker commented May 7, 2015

What values did you pass in the options variable?
Please make sure to you include the following value:

options.put("resource_type", "video");

As for the returned url, it doesn't require an extension - it works as is. However if you wish to specify the format, you can add an extension ('mp4', 'ogv', or 'webm') and the video will convert to that format. Adding an image extension 'jpg' or 'png' will return an image ("thumbnail") of the video. Adding 'gif' to the url will produce an animated GIF from the movie.

To checkout more options, see the Video management documentation.

@tocker tocker self-assigned this May 7, 2015
@coomar2841
Copy link
Author

@tocker Thanks for you response. This works, after I followed the new announcement on the website, and tried it out. I will close this issue now.

@grath92
Copy link

grath92 commented Apr 11, 2016

File file = new File(filePath);
JSONObject cloudinaryResult = new JSONObject(cloudinary.uploader().upload(file, ObjectUtils.asMap("resource_type", "image")));

System.err: at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:50)
04-11 19:03:48.920 18295-18295/com.gkr.locationfeatcher W/System.err: at com.cloudinary.Uploader.callApi(Uploader.java:22)
04-11 19:03:48.920 18295-18295/com.gkr.locationfeatcher W/System.err: at com.cloudinary.Uploader.upload

Image not upload in Android
Plsss help..
Thanks..

@lby1992
Copy link

lby1992 commented Aug 2, 2017

@tocker thanks for your answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants