Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 Presigned URL upload image with postman

I need to upload a file to S3 with postman for testing. I have a generated presigned URL from S3.

But I don't know how to configure postman correctly for doing this PUT request to my generated presigned URL.

The response on postman with malformed headers is:

<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>

the params for the presigned request:

const params = {
  Bucket: 'ss-files-dev',
  Key: 'dansero.jpg',
  ContentType: 'image/jpeg',
  Expires: 100
};

I get the URL, then enter it in postman, with PUT request, but the headers are not complete? 1. if I add content-type on header, there is no response from server 2. in body for the request Im attaching file as "binary"

postmanConfig

How to do my PUT request from postman?, thanks

like image 301
manuelBetancurt Avatar asked Jul 19 '18 01:07

manuelBetancurt


People also ask

How to upload files to AWS S3 using a pre-signed url?

AWS S3 provides different ways to upload your files to an S3 bucket. One of the ways to upload your file to S3 storage is using a pre-signed URL. The following steps are used to upload a file in the S3 bucket using a pre-signed URL. Create and API which accept the filename of the file to be uploaded to the S3.

How to upload a JPG file to S3 from Postman?

Navigate to the S3 console, and open the S3 bucket created by the deployment. In the bucket, you see the JPG file uploaded via Postman.

How do I upload an object to Amazon S3?

You can use the AWS SDK to generate a presigned URL that you or anyone that you give the URL to can use to upload an object to Amazon S3. When you use the URL to upload an object, Amazon S3 creates the object in the specified bucket.

How do I generate a presigned URL programmatically using AWS?

You can generate a presigned URL programmatically using the AWS SDKs for .NET, Java, Ruby, JavaScript, PHP, and Python. You can use the AWS SDK to generate a presigned URL that you or anyone that you give the URL to can use to upload an object to Amazon S3.


3 Answers

For me, Postman added hidden headers. If I remove the Content-Type header, the Put worked as expected.

like image 126
user714157 Avatar answered Oct 17 '22 10:10

user714157


Make sure about the following things:

1-The file name equal and same as the key when you get the signed URL.

2-Get the signed URL for putObject by passing the right parameter to getSignedUrl.

For put request not needs to set any additional headers.

like image 24
Reza Mousavi Avatar answered Oct 17 '22 09:10

Reza Mousavi


I was able to get this working in Postman using a POST request with “form-data” input. I put all the details in this stack overflow post.

like image 2
mojoken Avatar answered Oct 17 '22 09:10

mojoken