Closed namhihi237 closed 12 months ago
Hey there, thanks for getting in touch.
It seems you have an error in your code. The signature needs to be generated with the API Secret, rather than key. Could you please update your code to the following and let us know if you are then able to upload?
generatePresignedUrl() {
const { cloudName, apiKey, apiSecret } = this.configService.get('cloudinary');
const timestamp = Math.round(new Date().getTime() / 1000);
const signature = cloudinary.utils.api_sign_request({ timestamp }, apiSecret);
return `https://api.cloudinary.com/v1_1/${cloudName}/image/upload?api_key=${apiKey}&signature=${signature}×tamp=${timestamp}`;
}
Ah, Thanks for pointing out. It's works.
Bug report for Cloudinary NPM SDK
I am use "cloudinary": "^1.41.0",
Describe the bug in a sentence or two.
Can not upload image by presigned URL, get the error
Invalid signature
Issue Type (Can be multiple)
[ ] Build - Can’t install or import the SDK [ ] Babel - Babel errors or cross browser issues [ ] Performance - Performance issues [ ] Behaviour - Functions aren’t working as expected (Such as generate URL) [ ] Documentation - Inconsistency between the docs and behaviour [ ] Incorrect Types - For typescript users who are having problems with our d.ts files [x] Other (Specify)
Steps to reproduce
I have API return presigned url to upload
Error screenshots
I am getting an error when posting presiged url
Browsers (if issue relates to UI, else ignore)
[ ] Chrome [ ] Firefox [ ] Safari [x] Other (Specify) [ ] All
Versions and Libraries (fill in the version numbers)
Cloudinary_NPM SDK version Node - v20.9.0 NPM - 10.1.0
Config Files (Please paste the following files if possible)
Package.json
Repository
If possible, please provide a link to a reproducible repository that showcases the problem