Invalid signature - String to sign
I’m having a problem with image uploads.
I have the app running on heroku. I’m using Node for my backend. The app runs fine, until a user tries to post an image. I then get the following error message:
Invalid Signature ****************************************. String to sign - 'timestamp=**********.
I used the same setup in another app, and it works fine. I’ve followed some stack overflow threads on the problem, but I’m not getting a useful answer.
I’ve set up the environment variables in heroku the same way I did on another app, and it works. I’ve also installed the cloudinary and multer packages in my package.json file.
Any ideas what I’m doing wrong here?
Below is my code:
var multer = require('multer');
var storage = multer.diskStorage({
filename: function(req, file, callback) {
callback(null, Date.now() + file.originalname);
}
});
var imageFilter = function (req, file, cb) {
// accept image files only
if (!file.originalname.match(/\.(jpg|jpeg|png|gif)$/i)) {
return cb(new Error('Only image files are allowed!'), false);
}
cb(null, true);
};
var upload = multer({ storage: storage, fileFilter: imageFilter});
var cloudinary = require('cloudinary');
cloudinary.config({
cloud_name: 'digi9mjbp',
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
});
-
Hey,
I'm sorry for the delay in the response here!
I'm happy to hear that you found the solution in a different thread.
-1 -
Shirly et al,
It is not helpful to users who might have the same problem t say that the solution is in a differnet thread,
without providing a link to the solution.
abg
1 -
Hi Ashlinga,
I believe the poster of this thread also contacted us directly and Shirly saw that he figured out his issue separately- it's not likely that Chris' problem is identical to yours because the problem when this message is received is usually specific to the customer's code, which is most likely different to yours. If it helps, I believe Chris' issue was related to the configuration of the SDK - the cloud name, API key or API secret wasn't correct.
If you're having trouble with your signature creation code, please take a look at this summary of how signatures are used in Cloudinary: https://cloudinary.com/documentation/signatures
And this section of the documentation specific to creating authentication signatures: https://cloudinary.com/documentation/upload_images#generating_authentication_signatures
The most likely reason you'll see this error, assuming the API secret and timestamp are correct, is that there's a mismatch between the parameters you used in your signing function and those which were sent to the server,The error message tells you which parameters our server was expecting to be used in the signature creation, so you can compare that to what you signed and what you send to the server, to verify your implementation is correct.
If you're still having trouble, please create a request for our support team and include your signing code and the error you received, and we'd be happy to help
Thanks,
Stephen
0
Post is closed for comments.
Comments
3 comments