I can't seem to generate the correct signature to upload an image successfully.
Error message -
message:'Invalid Signature 953e29c9b5cac0f611e347d508aaff75f11f0547. String to sign - 'timestamp=1631318071'.'
Maybe someone can tell me what I'm going wrong? Maybe the order of something (according to the docs)?
FYI - I tried changing the order I pass in the parameters server side but it didn't seem to do much to successfully upload.
Here is how I generate the signature client side (C#) and pass data to the client (Angular)
DateTime foo = DateTime.Now;
long timeStamp = ((DateTimeOffset)foo).ToUnixTimeSeconds();
var p = new Dictionary<string, object>();
p.Add("api_key", _cloudinaryConfig.Value.ApiKey);
p.Add("api_secret", _cloudinaryConfig.Value.ApiSecret);
p.Add("cloud_name", _cloudinaryConfig.Value.CloudName);
p.Add("timestamp", timeStamp);
var signature = _cloudinary.Api.SignParameters(p);
return Ok(new {
cloudUploadUrl = _cloudUploadUrl,
cloudName = _cloudinaryConfig.Value.CloudName,
cloudApiKey = _cloudinaryConfig.Value.ApiKey,
cloudSignature = signature,
cloudTimeStamp = timeStamp
});
Here is the client trying to upload an image in Angular
const data = new FormData();
data.append('file', croppedImage.base64);
data.append("api_key", cloudinaryParams.cloudApiKey);
data.append("signature", cloudinaryParams.cloudSignature);
data.append("timestamp", cloudinaryParams.cloudTimeStamp);
const fileResult = await fetch(cloudinaryParams.cloudUploadUrl, {
method: 'POST',
body: data,
});
const fileData = await fileResult.json();
if (fileData.error) {
// do something to handle the error!
}