{ result: 'not found' }
silver_seeker
Member Posts: 1 ✭
Hey ,I'm always getting this response whenever I send a delete request to my files.
this is my function
(async function upload() {
const result = await cloudinary.uploader.destroy(
"http://res.cloudinary.com/dw3oy1kwb/image/upload/v1690553921/avatars/td4uoxclnlmm8xhiutzo.png",
{ folder: "avatars" }
);
console.log(result);
})();
Tagged:
0
Best Answer
-
Hi @silver_seeker ,
When using the
destroy()
method, the first parameter should be thepublic_id
and from the code you shared, I see you are passing a URL. Due to this, you're getting the error (correctly) because no public_id with the value you supplied exists in your cloud.To resolve the issue you will want to make the following changes:
- Removing the
folder
parameter since that is not relevant fordestroy()
calls. Please see the Documentation for the destroy() method (https://cloudinary.com/documentation/image_upload_api_reference#destroy) with details of all accepted parameters by this method/endpoint. - The public_id of the asset based on the URL you shared will be
avatars/td4uoxclnlmm8xhiutzo
- therefore, if you supply this as the first parameter to the destroy() method your request should work. Please see this section of the Documentation in regards to the Public ID - https://cloudinary.com/documentation/cloudinary_glossary#public_id - Optionally, you can also include the
invalidate
parameter set totrue
if you would like the CDN cache to be invalidated such that existing URLs of the deleted asset will now return 404 errors (when accessed) rather than potentially returning a cached copy of the deleted asset.
Please try this out and let us know if it works for you.
1 - Removing the