1
votes

I'm working with the Cloudinary API and it's very straight forward but I'm having no luck deleting an image via my app.

I've got uploads working but not deletions which is the weird part.

I'm able to access the API from the server and view the method like this in a console.log

Meteor.methods({
  deletePhoto: function (public_id) {
    console.log(cloudinary.v2.uploader) // I can see methods on this

    cloudinary.v2.uploader.destroy(public_id, function(result) {
      console.log(result);
    });

  }
});

but once I pass it the image's public_id to to the destroy method, it errors:

Exception while invoking method 'deletePhoto' undefined

Here's the docs. http://cloudinary.com/documentation/node_image_upload#update_and_delete_images

1

1 Answers

1
votes

When invoking API v2, your callback should accept two arguments: error and result.

Try changing your code to:

Meteor.methods({
  deletePhoto: function (public_id) {
    console.log(cloudinary.v2.uploader) // I can see methods on this

    cloudinary.v2.uploader.destroy(public_id, function(error, result) {
      console.log(result);
    });

  }
});