Can someone advise me how to delete a file in Cloudinary using Jquery?
I can't find any sample snippets to get started.
Can someone advise me how to delete a file in Cloudinary using Jquery?
I can't find any sample snippets to get started.
There good documentation on deleting client side uploaded images.
There are a few caveats to note though:
This does not work with unsigned uploads.
You will have to set return_delete_token: 1
in the options during your file upload, then pass the returned image's delete_token
to the cloudinary.delete_by_token(delete_token)
method.
From the documentation, you can do this over REST like so: curl https://api.cloudinary.com/v1_1/demo/delete_by_token -X POST --data 'token=delete_token'
Deleting resources requires an authenticated API (including a signature). Since the signature is based on your account's api_secret
which shouldn't be included in your client-side code, you'll need to generate the signature on the server-side.
Having said that, when uploading you can set the new return_delete_token
to true
to tell Cloudinary to return a deletion token as part of the upload response.
The token can be used to delete the uploaded image within 10 minutes using an unauthenticated API request.
This is done with the delete_by_token
method. See the following for a reference:
https://github.com/cloudinary/cloudinary_js/blob/47cf97a07f063a32311ff7d7cd09dc5a5a919318/js/jquery.cloudinary.js#L598