Cannot figure out why the image is not deleting

Options
padawan
padawan Member Posts: 2 āœ­

I'm trying to delete an image using the Nodejs SDK.

const result = await cloudinary.uploader.destroy(profile.id);

But it returns a result of 'not_found' even though I'm specifying the correct public id

As you can see in the pics above, the id of the resource in the media lib matches what is in the console (profile.id = 65aaba8df62ba670bac1af73)

Best Answer

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 123 admin
    Answer āœ“
    Options

    Hi there,

    Thanks for reaching out.

    In your screenshot, I see that the asset is located in a folder profile_pictures. The folder is part of the public id, so you will need to include the folder when you pass the public id to the destroy method.

    As an example, if you had an asset with the filename of 'cuteKitten' and that was located in a folder 'cuteAnimals', the entire public id would be cuteAnimals/cuteKitten and your destroy call would look like this:

    cloudinary.uploader.destroy("cuteAnimals/cuteKitten").then((result) => console.log(result));
    

    Can you make that adjustment and give it another try? Let me know how it goes and if you have any questions, do not hesitate to ask.

    Kind regards,

    Tia

    Helpful Links For You
    šŸ’¬ Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    šŸ§‘ā€šŸŽ“ Join our Cloudinary Academy for free courses, workshops and other educational resources.
    šŸ“„ Read our documentation for in-depth details on Cloudinary product features and capabilities
    šŸ“° Check out the Cloudinary blog for the latest company news and insights

Answers

  • padawan
    padawan Member Posts: 2 āœ­
    Options
  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 123 admin
    Options

    Hi there,

    Thanks for the update. I'm glad you got it working šŸ˜Š

    Kind regards,

    Tia

    Helpful Links For You
    šŸ’¬ Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    šŸ§‘ā€šŸŽ“ Join our Cloudinary Academy for free courses, workshops and other educational resources.
    šŸ“„ Read our documentation for in-depth details on Cloudinary product features and capabilities
    šŸ“° Check out the Cloudinary blog for the latest company news and insights