8

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 - enter image description here
------------------------------------------------------------------------------ enter image description here

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.

Dev1ce
  • 5,390
  • 17
  • 90
  • 150
  • I did not know AWS but if you somehow define the algorithm in your code, you may success at operation. Maybe the system tries to parse the key depend on its default algorithm (i.e MD5). But the key looks like some other like SHA-256. – stuck Oct 29 '19 at 09:35

1 Answers1

4

Postman added hidden headers. If I remove the Content-Type header, The Put request will work as expected.

enter image description here

Ahmed Mehanna
  • 141
  • 3
  • 10