Cloudinary Invalid image file exception
Asked Answered
D

2

12

Cloudinary only has an example for how to load images from android to the cloud. However I need to upload videos. When I use the call from the sample code I get an Invalid image file error. Here is the call that throws the exception

Map cloudinaryResult=cloudinary.uploader().upload(file, uploadParams);

Does anyone know the call for uploading videos instead of photos? I am using Cloudinary with Parse.com

Here is the stack trace

java.lang.RuntimeException: Invalid image file
            at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:101)
            at com.cloudinary.Uploader.callApi(Uploader.java:22)
            at com.cloudinary.Uploader.upload(Uploader.java:55)
Dilatometer answered 30/9, 2015 at 23:30 Comment(1)
also my url only has alpha and dashes as in abce_efgh_ijklm_nopqu_st.mp4Dilatometer
S
16

You should add

uploadParams.put("resource_type", "video")

to tell Cloudinary that you want to upload video. Or,

uploadParams.put("resource_type", "auto")

to let Cloudinary determine the file's content.

Sordino answered 1/10, 2015 at 12:16 Comment(4)
It would be nice if these guys included this information in their samples or documentations. This is an unnecessary barrier to entry and waste of time. Maybe I should look into their competitors :). But check and plus one to you. Thank you.Dilatometer
@KatedralPillon who are their competitors?...doesnt seem to be much offerings in this space...sans DIY recipes...Dittany
@KatedralPillon I couldn't agree more. The docs for their iOS github repo are terrible.Sagacity
I need to upload pdf file to cloudinary i tired to use source type auto and I got Invalid resource.Iridescence
C
0

Though this question is old, for those using PHP/Laravel and still facing this issue:

A. To upload an image:

  1. In your request validation:

    'avatar' => 'mimes: jpeg, png, jpg',

  2. then upload the image to Cloudinary as shown below:

    $image = Cloudinary::upload($request->file('avatar')->getRealPath(), ['folder' => 'projectName/avatar'])->getSecurePath();

B. To upload documents and file such as csv, doc,docx, pdf, sql, txt, and zip):

  • In your request validation:

    'document' => 'mimes: pdf, doc, docx, sql, txt, zip, csv'

  • then upload the document or file as shown below:

$documents = Cloudinary::uploadFile($request->file('document')->getRealPath(), ['folder' => 'projectName/documents'])->getSecurePath();

Important note.

  • Please take note of the "upload" when dealing with images and "uploadFile" when dealing with files and documents.

  • Ensure to make the necessary settings in your Cloudinary "Upload Presets" settings as shown below:

enter image description here

Congratulations!

Cullis answered 13/1 at 5:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.