Delete an asset from Cloudinary
Wondering about how do you delete an existing asset from your Cloudinary media database? Have a look on this quick guide to find the solution! :)
If you have read the previous guide "Upload image to Airtable", you might remember we used the Cloudinary Media Database to host our image temporarily until it's uploaded to Airtable.
Now, it only makes sense if we delete the temporarily-hosted image from Cloudinary, as it's of no use now. The Cloudinary Upload API has a method for this particular purpose, known as the destroy method.
Click here to view the API reference of destroy
method.
Quick Look - Delete an image from Cloudinary Media Database
POST
https://api.cloudinary.com/v1_1/<cloud_name>/image/destroy
The destroy
method is used to immediately and permanently delete a single asset from your Cloudinary
Request Body
public_id
String
(required) The public ID of the image
signature
String
(required) Signature for authentication
timestamp
String
(required) Current time in UNIX format
api_key
String
(required) Cloudinary API key
API Parameters
As you can see in the above API module, there are 4 required parameters. Let's have a brief look at their use -
public_id
- The value for thepublic_id
parameter can be easily extracted from the direct URL of the image. For example, in the URL https://res.cloudinary.com/demo/..../cat.jpg, "cat" is the public ID of the image.timestamp
- The current UNIX time. The value for this parameter can be extracted from the seconds since 1970 block in device category in the Blocks section of your project.api_key
- The API key of your Cloudinary account. The API key can be found on the top section in your Cloudinary account dashboard (cloudinary.com/console).signature
- The value for thesignature
parameter (which is the authentication parameter) is a hash value (SHA1 encryption) of a string, which is a combination of a few parameters. The parameters involved are as follows -public_id
- The same public_id we used in the body parameters above.timestamp
- The same timestamp we used in the body parameters above.api_secret
- The API secret of your Cloudinary account. Also located alongside the API key in the account dashboard.
Generating the SHA1 Signature
Generating the Signature for authentication is a hefty task. But don't worry, I've made it simpler for you. Let's have a look at the steps to produce an SHA1 signature -
The offline SHA1 encryption module
As I said earlier, we need to combine together a bunch of values and encrypt it with SHA1. There are plenty of online APIs for this, but I do not trust anyone of them with my data. So I did some coding, and I made my own SHA1 encoder using HTML, JS, & PHP, to use along with the WebViewer's postData and receiveMessage in Thunkable. Below attached sha.html file
Assuming you have the values for public_id
, timestamp
, & api_secret
, we'll now join/combine the values using the join
text block like this -
Last updated