How to delete images from cloudinary

You need to use the public_id and the timestamp and follow it by the secret key.

Use the hashify API and you will get the correct signature. I know because I use it and it works.

I also took the sample data in Cloudinary documentation and run it through the API and got the same signature in the documentation.

1 Like

I looked at your code. You are not passing any parameters to the hashify API and therefore you are not creating the correct signature.

Use the suggestion in the error message and add to it your secret key and make it as the body of your first API.

So, assuming your secret key is abc123def987 then the body of the hashify API would look like this


The text part is public_id=y5b9oqtyqge6z3m2wwhf&timestamp=1626015856abc123def987

1 Like

As I told I am a beginner I am sorry.
Now I changed my code like this.


Now I get this error. “Upload preset must be whitelisted for unsigned uploads”.

I have added unsigned and signet preset in cloudinary
this is the screen shot of cloudingnary…


What should I do next
Thanks

1 Like

I can see 4 obvious mistakes.

  • Timestamp, according to documentation is UNIX time and you are using the seconds since 1970 block which has a decimal part. You need to get rid of it.
  • The body section of the Hashify does not include the secret key which will lead to wrong signature.
  • The query section of Cloudinary API should be an object and you coded it as text.
  • The destroy command does not require a “file=” as part of the parameters.

Hope this helps you to get code it correctly.

I use it another way to delete images.
Set your api URL to this: https://api.cloudinary.com/v1_1/XXX/resources/image/upload/
where XXX is your cloud name
Then, pass only one query parameter: public_ids
This parameter must receive your url file name, without path and extension.
Then you call DELETE method of api.

1 Like

Yes, this is part of Admin API resources which you can delete up to 100 images in one single call.

I changed like this now I get previous error “Invalid signature”

my project link
https://x.thunkable.com/copy/0d8ff07bf84ed81479a26d599c65ab63

1 Like

Of course it will be invalid signature.
The body section of the first URL should include only the following:
public_id
timestamp
secret key

You are using signature in the first URL which is WRONG.

I cannot help you with the project because I do not have your secret key. You are the only one who can add it to the body section of the first URL to create the correct signature.

this is my secret key
KqB8gbWAY27wvMQvgh

1 Like

I encourage you to remove sensitive info from the forum.

This is the body section of the Hashify API
image

The public_id should be referring to the image. If you uploaded the image using the MediaDB component of Thunkable then the the public_id will be very similar in construction and format to the secret key you provided.

Sorry to reveal my secret key, as this is trial after that I will change my key.
Are you able to open my project?.
I changed as you said but same error.

Thanks

1 Like

I’ve noticed you change the URL to “upload” the details are for “destroy”. I will check it later.

I kept getting invalid signature with all the attempts and modifications I did and then I decided to use the credentials of my Cloudinary account and I immediately go this

This is correct because the public id is not in my Cloudinary account.

Result is: you have something wrong with either your API key or your Secret key or your public_id

I now created a new account in cloudinary, then also I get the same error.

Proj link: https://x.thunkable.com/copy/94c37faaa7e5f7bde28da56bd5efe2b0

Thanks.

1 Like

Check this.

I changed the code a bit and used a photo from the net (I did not use “select” option)

You can upload the image then test your own account to see that the photo is uploaded.
You can then use the delete option to remove it from your Cloudinary account.

https://x.thunkable.com/projectPage/60f13c644a6596001191d3fc

3 Likes

Thank you very much now it is working fine.
I found one more problem by using photo library. I assigned Photo from Photo library to a label, here I get “file:///…” which shows invalid URL. Is there any solution to get file path correctly?.

I Used Media DB for uploading and took public Id from its URL like this.
I want to know weather I am doing right or any method.


Any how it is working for delete.
Thanks.

1 Like

If you use Media DB to upload your images then the public_id is the image file name without the extension (.jpg or others).

But how can we get file name and path from camera or photo library?

1 Like

The cloudinary API requires full URL of the image starting with “http or https”. I does not recognise URL starting with “file://”

You will need external code to upload files directly from the phone to Cloudinary using API.

Media DB component takes care of this process.

So there is no way to get file path for uploading using photo library. Can we use any external code in thinkable?.

Thanks

1 Like