Question

I am experimenting with libcurl for a multipart upload to s3. My initiate multipart request looks like this

POST /my_new_file.mbi?uploads HTTP/1.1 Accept: / Host: test_bucket.s3.amazonaws.com Date: Thu, 01 May 2014 13:35:17 GMT Authorization: AWS4-HMAC-SHA256 Credential=XXXXXXX/20140501/us-east-1/s3/aws4_request,SignedHeaders=host,Signature=1a3fd6195040494dd95507455a3b1eefef40346485e3fdafbe6cc136192365a2

I get the following response

The provided 'x-amz-content-sha256' header must be a valid SHA256.

s3 documentation says we do not need any other headers for Initiate multipart upload call(POST). Have tried with various combinations of signed empty content, but no luck.

What am I missing here? Any suggestions here will be very helpful.

Thanks

Was it helpful?

Solution

I haven't used version 4 auth, yet, for multipart uploads (my code uses v2), but I did find this:

x-amz-content-sha256

When using signature version 4 to authenticate request, this header provides a hash of the request payload. For more information see Authenticating Requests by Using the Authorization Header (Compute Checksum of the Entire Payload Prior to Transmission) - Signature Version 4. When uploading object in chunks, you set the value to STREAMING-AWS4-HMAC-SHA256-PAYLOAD to indicate that the signature covers only headers and that there is no payload. For more information, see Authenticating Requests Using HTTP Authorization Header (Chunked Upload).

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonRequestHeaders.html

Obviously, chunked and multipart are not the same thing, but perhaps this value is also appropriate for a multipart upload request, or will generate a new and more helpful error message. The documentation seems unfortunately sparse in this case.

OTHER TIPS

For Googlers who got this error:

Missing required header for this request: x-amz-content-sha256

While using awscli, what worked for me was setting the region correctly in the file ~/.aws/config (I'm using Ubuntu) to us-east-1. US only doesn't work nor does US Standard. The returned error doesn't really indicate that.

STREAMING-AWS4-HMAC-SHA256-PAYLOAD appears to no longer work. I was able to make it work by passing the SHA256 hash of the empty string, e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top