Cannot figure out why the image is not deleting
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
-
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 insights1
Answers
-
Yeah this worked, thanks
0 -
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 insights0