简体   繁体   中英

can not add file in aws s3 bucket using postman

I am trying to add a file in s3-bucket in my AWS account using postman. see below screenshot.

在此处输入图像描述

I pass Host in the header as a divyesh.vkinds.com.s3.amazonaws.com where divyesh.vkinds.com is my bucket name. and in Body I am giving file as index.html as file type like image below.

在此处输入图像描述

but it is giving me The provided 'x-amz-content-sha256' header does not match what was computed. error. I searched for it but can't find anything.

Please check content-header. Add Content-Type as text/plain and date in this format XX-XX-XXXX

I have also faced the same problem. The issue was that, postman does not calculate the SHA. It defaults to a SHA of empty string e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

So in the postman headers, add an explicit key x-amz-content-sha256 . Caluclate the value of SHA256 for your file using a sha command and provide as the value. Below command works on linux flavors

shasum -a 256 index.html

Couple of other observations in the question.

  1. You can change the Body as binary and choose the file you want to upload.
  2. Provide the complete path including the file name in the upload URL. Eg if you provide the URL as <your bucket name>.s3.<region>.amazonaws.com/test/index.html, the file will be copied to test directory in the bucket with name as index.html

I encountered this situation recently, and the issue was that I was copying an active log file which changed between when my side calculated the hash and when the file was actually uploaded. My solution was to copy the file to a temporary location, then upload that stable file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM