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: 135 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: 135 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