Signed bulk upload with curl
I want to upload a huge amount of images with a batch file using curl. Cause of security reasons I want to use signed upload. So I created a signature as described in https://support.cloudinary.com/hc/en-us/community/posts/360000183051-File-upload-using-curl-) It was not complete clear for me what string I have to use for the sha1 key. I tested it with the api secrect alone cause i have no transcode parameters and the following batch:
FOR /F %%a IN ('dir /b "%ImageDir%\*.jpg"') DO (
curl -o result0 -F "upload_preset=%upload_preset%" -F file=%ImageDir%\%%a&api_key=someapikey&signature=somesignature" http://api.cloudinary.com/v1_1/%cloud%/image/upload
)
I got alwas the response: {"error":{"message":"Upload preset must be whitelisted for unsigned uploads"}}
But I wanted to use signed uploads. Can you please give me a hint how to do this?
-
Hi,
Structure of the curl image upload: curl https://api.cloudinary.com/v1_1/<cloud_name>/image/upload -X POST --data 'file=<url of image>×tamp= <current unix timestamp>&public_id=<insert public_id>&transformation=<insert transformation>&api_key=<your api key>&signature=<generated signature>'
If we want to upload sample image with transformation w_200,h_200,c_limit and public id=sample then the signature will be comprised of
1. public id
2. timestamp(epoch timestamp)
3. transformation and
4. generated API secret/signature(Note that this is not your account API secret key but a generated signature)
In this case the signature parameters will be - public_id=sample×tamp=1514500082&transformation=w_200,h_200,c_limit<Insert your API secret here without comma or space>
The signature is generated using SHA-1. Since you are using signed upload, you don't need to use upload preset.
For more information on signatures: https://cloudinary.com/documentation/upload_images#creating_api_authentication_signatures
Regards,
Aditi0 -
Hello Aditi,
I rewrote the code exactly how you wrote:
curl -k https://api.cloudinary.com/v1_1/%cloud%/image/upload -X POST --data "file=%ImageDir%\%%a×tamp=15741687674&public_id=%%a&api_key=<somekey>&signature=<somesignature>"
but I got the message
"message":"Unsupported source URL: Images2\\IM04933
why are here two backslashes? the curl comman I've only one. How can I upload local files?
Could you help me to fix this? Why can't I transmit simply the api key and secret via https?
Best regards
0 -
Hi,
Can you please open a support ticket here: https://support.cloudinary.com/hc/en-us/requests/new and share all the params you passed including the parameters you used to generate the signature and I will be able to assist you better.
Regards,
Aditi0
Post is closed for comments.
Comments
3 comments