Question:
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 –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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 –
1 2 |
https://some-bucket.s3.amazonaws.com/test/image.jpg?AWSAccessKeyId=ABCDxxx&Expires=1572339646&Signature=someSignaturexxx |
Here is the Postman response –
1 2 3 |
SignatureDoesNotMatch |
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.
Answer:
Postman added hidden headers. If I remove the Content-Type
header, The Put
request will work as expected.