Meteor: Cloud

I am trying to upload a photo using Lepozepo / cloudature

This is the configuration of my server and client

server:

Cloudinary.config({ cloud_name: '*****', api_key: '******', api_secret: '********' }); 

customer:

 $.cloudinary.config({ cloud_name: "*******" }); 

I tried to upload an image using the form

html form code:

 <form> <input type="file" id="userimage" name="userimage"/> <button type="submit">Upload</button> </form> 

And this is mine, this is an event for the template

 Template.signup.events({ // Submit signup form event 'submit form': function(e, t){ // Prevent default actions e.preventDefault(); var file = $('#userimage')[0].files[0]; console.log(file) Cloudinary.upload(file, function(err, res) { console.log("Upload Error: " + err); console.log("Upload Result: " + res); }); } }); 

When I click the download button, nothing happens, I just got an error message

  error: uncaught TypeError: Failed to execute 'readAsDataURL' on `'FileReader': parameter 1 is not of type 'Blob'.` 

What can I do to make this work?

+5
source share
3 answers

I found a way to solve it.

  • Lepozepo / cloudinary Cloudinary.upload parameter of the method file is an array, I just add this code:

     var files = [] var file = $('#userimage')[0].files[0]; files.push(file) console.log(files) 

And it works great

+2
source

Use "_upload_file" instead of "upload". "_upload_file" is actually used in upload. But for some reason you cannot catch the error and the answer when using "upload"

You can catch the error and the answer.

Meteor Version: 1.1.0.3

lepozepo: cloudinary: 1.0.2

 Cloudinary._upload_file(files[0], {}, function(err, res) { if (err){ console.log(err); return; } console.log(res); }); 
+3
source

I will fix this in the source right now to accept individual files. But yes, the Cloudinary.upload function expects Cloudinary.upload(files) , not Cloudinary.upload(files[n])

0
source

All Articles