Cloudinary has a photo_id that is assigned once the photo is uploaded, but I don't know how to retrieve it. I'm using Meteor. Below is the code for users to upload a photo.
Template.userProfile.events({
'submit form': function(e, t) {
e.preventDefault();
var files = [];
var file = $('#userimage')[0].files[0];
files.push(file);
Meteor.call('uploadPhoto', Meteor.userId(), "test")
Cloudinary.upload(files, function(err, res) {
console.log("Upload Error: " + err);
console.log("Upload Result: " + res);
});
},
});
I would like to use the code below to set the photoId or url as a field for the user JSON object.
uploadPhoto: function(userId, photoId) {
Meteor.users.update(userId, {
$set: {photoId: photoId}
});
}
When I test for the res:
var i = [];
Cloudinary.upload(files, function(err, res) {
i.push(res.public_id)
console.log(i)
});
console.log(i)
The console.log just shows an empty array.