I'm trying to integrate Cloudinary in my project for uploading images. I have just started using the following links:
http://cloudinary.com/documentation/node_image_upload https://github.com/cloudinary/cloudinary_npm/blob/master/samples/basic/basic.js
I'm stuck at a point where I can see the image uploaded to Cloudinary in my dashboard but in my code the response is undefined.
Code:
cloudinary.config(config.cloudinaryConfig);
function uploadFileInCloudinary(fileObj, callback) {
console.log(fileObj);
if(fileObj && (fileObj != undefined)) {
console.log(fileObj['path']);
cloudinary.uploader.upload(fileObj['path'], function(err, result) {
if(err) {
callback(err);
}
console.log("cloudinary result");
console.log(JSON.stringify(result)); // undefined
callback(null, result);
});
} else {
callback("error");
}
}
Why is it so? Can anyone give me some pointers to where am I doing wrong?
callback(err)
, is it possible that you are missing error response by callback being called twice? – Paweł Sroka