[Solved] Creating a cloudinary signature for API POST call

I have updated the generator to include a private overload. What Stephen suggested works for me (as in theory). Save as private and share a signed link including a named transformation. This way I can share the image, scaled and watermarked, and the end user cannot access the original image.

image

I’ll set up a Cloudinary Generator app soon. So you can 1. generated a curl example and 2. inspect the blocks.

Ta
James

I’ll set up the generator app when the current project is ready for live testing. Here are some working blocks.




Uploading as private allows for derived image urls links can be shared so no eager transformation required
image

I hope these can assist others.

James

2 Likes

Thanks @japa6225a - this is really thorough and very helpful. Thanks for sharing this with the Community! :+1:

Could you share the link

I would mate but what worked one day, didn’t the next. I decided to try a different way to get the Signature as this is the bit I had the most issues with just like some other. When I have a constant version, I will create a demo app. If only Thunkable had SHA1 encryption included.
I do know that I am using Cloudinary for a purpose it is not really designed for but these challenges drive me. Mostly mad but drive me :rofl:

2 Likes

Good luck! I am really looking forward to your result as well. :joy:

Think I finally have it @tatiang, @skulamester and others.
Using Convert Curl to HTTP Request yesterday I realised that the hashify was not returning the right hash from the url parameters using thunkables webapi url alone. Add the header and the text to as the body and fist pumps. Still testing but the first 10 or so have worked :grin: :crossed_fingers:

2 Likes

Hi @japa6225a!

Thank you for your research and sharing all the results with us, but I have a question. The eager does not work for me, I want a 200x200 image to be uploaded, but I hadn’t succeed. I hope you have some idea.

My blocks:

What I get:
image

1 Like

Yes. This I have found out too (haven’t been successful yet). Cloudinary is designed for web based applications. Yes, you can upload but the eager is used for showing the uploaded image on your site/app. So we have been trying to use cloudinary for image editing when it is only a transformation. Just today I finally got a new error, “file:///” url is not supported? FFS. So I am now back to image
and then use the returned url to make a new image to make it a private image. Then in the response, there are 2 url’s which I grab the Secure URL and add a preset transformation. In this case, resized for quicker download and watermarked. https://res.cloudinary.com/meatoff6/image/private/s--zGMYLsFr--/t_MOTsel50p/MO6-Thirsty_Chiefs_Meatoff-MeatOff_team_1-a-Hand_in-1619512510.jpg
Another one I realised today (brain is getting slower :frowning: ) is the web api is asynchronous. @tatiang this might help your initial issue too if you haven’t found it already.
Wrapping Asynchronous (then do) blocks into a Synchronous Function resolves unpredictable results
With resizing, I have seen some say to add the image to a canvas and then resize but have not tried that one yet.

I am facing the same problem as well.

I tried this thing and solves all of my problems! Amazing!

1 Like

Hello. I didn’t understand how the problem was solved “file:///” url is not supported. Can you help me with more details?

What is it you’re trying to do? Are you wanting to transform an image stored in Cloudinary? Or make a transformation when an image is uploaded? Or something else?

I’ll admit to not understanding all of this post but… have you tried this method?

To date I take photos and through MEDIA_DB I upload to cloudinary. I needed to delete the photos on cloudinary. With a little research on the community I can now upload and delete if the image is on https: /// … but if it comes from a photo taken with a mobile phone or from an image gallery I have this error:

But if you’ve uploaded the image to Cloudinary, then you have a cloud-based url for that image. You wouldn’t be able to delete a photo stored on a phone using the Cloudinary API. The photo has to be stored in Cloudinary. You shouldn’t be using a file:/// url at all.

yes, but to speed things up, I would like to upload and delete with api_cloudinary. and the API upload files with https: // and not local files. I wanted to know if it was possible to remedy. Because alternatively I upload with cloudinary and delete with cloudinary api, of course.

1 Like

You can use the Camera/Media blocks to allow the user to upload photos to Cloudinary. But I don’t know of a way to use the API to upload a photo directly from the phone.

2 Likes

OK, all right!

1 Like

@Dario_Cappello
See this post

Thanks muneer, I try this modification now!

2 Likes

@muneer has a great solution linked there

Here’s another (slightly more advanced but alternative solution) for you @Dario_Cappello

1 Like

I’m joining this thread with a question. I am trying to change a cloud file. As far as I know you need parameters “from_public_id” “to_public_id” and signature and timestamp with key. Unfortunate error in generating the signature. It generates a key using this API https://api.hashify.net/hash/sha1/hex and giving the parameters: from_public_id=12345678&to_public_id=123&timestamp=“timestamp+key”. This method works fine with file upload. The file is uploaded to the cloud, but I still want to rename it and there is a problem in the signature.