I want to achieve the following -
1. Generate a signed URL
2. Upload a file (image.jpg), to the URL using Postman
I am using AWS Node SDK to create the URL,
Following is the code -
const AWS = require('aws-sdk');
AWS.config.update({
region: 'us-east-1'
});
const s3 = new AWS.S3();
var presignedPUTURL = s3.getSignedUrl('putObject', {
Bucket: 'some-bucket',
Key: 'test/image.jpg',
Expires: 3600
});
console.log(presignedPUTURL);
The code creates an URL like -
https://some-bucket.s3.amazonaws.com/test/image.jpg?AWSAccessKeyId=ABCDxxx&Expires=1572339646&Signature=someSignaturexxx
Here is the Postman response -
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
Postman call -
------------------------------------------------------------------------------
I tried following this -
https://medium.com/@aidan.hallett/securing-aws-s3-uploads-using-presigned-urls-aa821c13ae8d
I also tried various combinations, of the Key in code and filename to upload having the same name,
different Content-Type combination,
But no luck.
Go to Chrome > Settings, search for SSL (chrome://settings/search#ssl) and click on Manage certificates. Use the link again in Postman and it will work.
When you create a presigned URL, you must provide your security credentials and then specify a bucket name, an object key, an HTTP method (PUT for uploading objects), and an expiration date and time. The presigned URLs are valid only for the specified duration.
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that contains the object that you want a presigned URL for. In the Objects list, select the object that you want to create a presigned URL for.
Postman added hidden headers. If I remove the Content-Type
header, The Put
request will work as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With