Cloudinary jQuery plugin - upload from URL
Hi,
I'm trying to upload image from URL using Cloudinary jQuery plugin. I found this stackoverflow question http://stackoverflow.com/questions/17931075/upload-files-to-cloudinary-from-url-via-js suggesting I use
$('.cloudinary_fileupload').cloudinary_upload_url(url);
However after I used that approach, I get 400 Bad Request response on upload with following error message:
{"error":{"message":"Missing required parameter - file"}}
Any thoughts as to what I might be missing here?
Thanks,
Ivan
-
Hi Ivan,
Can you please post the relevant part of the html + js? If you can, a link to an online page would be even more helpful.
You can o pen a support ticket if you want to communicate privately.
0 -
For the record, problem was caused by delaying the upload process. I have overridden default fileupload 'add' event handler and called submit() method on the upload data manually. However cloudinary_upload_url() function relies on default behaviour.
The following solution was proposed - take cloudinary_upload_url() code from source ( https://github.com/cloudinary/cloudinary_js/blob/master/js/jquery.cloudinary.js):
$.fn.cloudinary_upload_url = function(remote_url) {
this.fileupload('option', 'formData').file = remote_url;
this.fileupload('add', { files: [ remote_url ] });
delete(this.fileupload('option', 'formData').file);
}
and manually submit form data BEFORE delete() call like this:
$('#clodinaryUpload').fileupload('option', 'formData').file = sourceURL;
$('#clodinaryUpload').fileupload('add', { files: [ sourceURL ] });
uploadData.submit();
delete($('#clodinaryUpload').fileupload('option', 'formData').file);In above example I use global variable uploadData for storing form data that is passed to fileupload 'add' handler.
0
Post is closed for comments.
Comments
2 comments