cloudinary
cloudinary copied to clipboard
Callback function not firing
Hi,
Appologies if this is a silly question, I'm still new to meteor. I'm trying to use the basic uploader for now, but I can't seem to get the callback function to fire from spacebars?
Everything else seems ok, the photos are uploaded, reports on progress, etc. $.cloudinary and the local collection _cloudinary all seem fine.
Not quite sure what I'm missing here, maybe some syntax issues? Any help would be very much appreciated!
Post the code so I can have a look :)
Sure
Method on server:
Meteor.methods({
save_url:function(response){
//console.log(response);
console.log('Add '+response.upload_data+' to the id of '+response.context);
}
});
In the view:
{{#c_upload_stream callback="save_url"}}
<input type="file">
{{/c_upload_stream}}
{{#each c.uploading_images}}
<p>{{percent_uploaded}}</p>
{{/each}}
I've also tried hooking into the local minimongo's after update with:
_cloudinary.after.update(function(user,file){
if(file.percent_uploaded === 100 && !file.uploading){
console.log(file);
}
});
I then get the following error in console:
TypeError: Cannot read property 'update' of undefined
at Template.posts-set.rendered (posts-set.js?8475729bfc469c2c4415c172c1d6866798d07328:12)
at template.js:116
at Function.Template._withTemplateInstanceFunc (template.js:437)
at fireCallbacks (template.js:112)
at null.<anonymous> (template.js:205)
at view.js:104
at Object.Blaze._withCurrentView (view.js:523)
at view.js:103
at Object.Tracker._runFlush (tracker.js:468)
at onGlobalMessage (setimmediate.js:102)
Photos are showing up in my Cloudinary media library, but I just can't seem to get the data_id back. I need to save it to a collection.
Thanks for your help!
That's strange that it doesn't work. I'll check for bugs as soon as I get a chance.
Thanks, really appreciate it!
One thing, when I query the local collection record, the uploading attribute is still set to true. Not sure if that helps in anyway.
+1
I tried both c_upload
and c_upload_stream
I get no errors in either client or the server however.
This anonymous function is never being called for me https://github.com/Lepozepo/cloudinary/blob/master/client/controllers.js#L54
Still poking at it but I've found something very weird, if I manually do Meteor.call('afterCloudinaryUpload')
before doing an upload I get an error as expected as I've not provided a response. However after attempting an upload trying to call it manually again I get no errors and no output in the console.
Hey! I'll take a look at it today. I've been busy closing one of my shops but now I'm in a sweet moment of "nothing else to do" WOOHOO!
Thanks @Lepozepo one last thing as I'm just heading out for a bit if you add this debugging into the server JS:
if(_.has(options,"callback")){
console.log('calling callback');
Meteor.call(options.callback,callback_options);
console.log('called');
}
The first message is logged but the 2nd is never logged.
I really can't figure this out so for now I've removed the callback param from the tag and using the _cloudinary.after.update
hook to then call my afterCloudinaryUpload
method with the file. Doing that is working for me at the moment.
I've just experienced something similar in my own code, trying to do a Meteor.call() serverside from within a Meteor.call() is causing the first method called to fail silently. Don't know if this is a core meteor issue or something to do with packages installed.
I think I have it figured out for me. My app was started from the meteor boilerplate which includes the https://github.com/matteodem/meteor-easy-security package by default. That has rate limiting on calling methods.
Added an issue over there https://github.com/matteodem/meteor-easy-security/issues/20
That makes sense, I'm also using the boilerplate with easy-security module
Wow, I don't think I would've figured that one out easily. After you remove easy security the package works?
I'm not actually using the c_upload_stream anymore but doing my own legwork (for various reasons) and then calling cloudinary_upload_stream
with the data directly. But I imagine it would, a very simple test is to take a working app and add he easy-security package it instantly kills the ability for methods to then do Meteor.call() for me.
Thanks DEfusion! I wasted my 2 hours just struggling to fix this issue before I saw your post.