Skip to content

S3 Multipart upload

0

im using esp32 and uploading sd card data over aws using s3 multipart. i received uploadid from aws s3 but for some reason unable to upload file chunks over aws , here is my request and response for initiate multipart

Request:- POST /folder_1/ad8232.txt?uploads HTTP/1.1 Host: <bucket_name>.s3<.region>.amazonaws.com x-amz-date: 20250109T070425Z x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Authorization: AWS4-HMAC-SHA256 Credential=***********/20250109/<.region>/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=7e277bdcd140f8e803befa31ab73a3c51726808eaf0df37609f460481f26643e Content-Length: 0

Response from S3 (Initiate): HTTP/1.1 200 OK x-amz-id-2: lMhWTp52Jmfcd7FspINI800fxuJnFFxQkkMOPCdik8/z45HTHX88eoawBHZ7xXblf3M0aIF9qIQ= x-amz-request-id: E0V9ACD17M8F8Q5S Date: Thu, 09 Jan 2025 07:04:28 GMT x-amz-server-side-encryption: AES256 Transfer-Encoding: chunked Server: AmazonS3

165

<?xml version="1.0" encoding="UTF-8"?>

<InitiateMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Bucket>esp32-multi</Bucket><Key>folder_1/ad8232.txt</Key><UploadId>qTHgZdday49QXHq6JqYYqvYMYfyyD7ksm0RJdCc4PUihIFSKGeCs5TIAO54QV44XX1O36lP7MvY59kE8q_VDzysyehMKDTwO02soL9764kabnNP7I0BdBANAdyMzXodo</UploadId></InitiateMultipartUploadResult> 0

and for upload part :::----

x-amz-request-id: HG8RFYA2ETBP4YWG x-amz-id-2: RgsGhui7GON4m3mOq6fcpN9ItSHXE1909eb+tjT1nkmDtExLL17H5S2eoEhLKRhdDmOORizNtXE= Content-Type: application/xml Transfer-Encoding: chunked Date: Thu, 09 Jan 2025 07:04:31 GMT Connection: close Server: AmazonS3

b7a

<?xml version="1.0" encoding="UTF-8"?>

<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>**********</AWSAccessKeyId><StringToSign>AWS4-HMAC-SHA256 20250109T070429Z 20250109/<.region>/s3/aws4_request 97706762e6363b40cc0c30d6ae0f06db1739e9041c3f8ddb03e432814ff2af4f </StringToSign><SignatureProvided>fc298c6223fa2b6ce4f10cdfde2f64174436f0fffd897d6fec060091e8ab5183</SignatureProvided><StringToSignBytes>*****************</StringToSignBytes><CanonicalRequest>PUT /folder_1/ad8232.txt partNumber=1&uploadId=qTHgZdday49QXHq6JqYYqvYMYfyyD7ksm0RJdCc4PUihIFSKGeCs5TIAO54QV44XX1O36lP7MvY59kE8q_VDzysyehMKDTwO02soL9764kabnNP7I0BdBANAdyMzXodo host:<bucket_name>.s3.<region>.amazonaws.com x-amz-content-sha256:71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73 x-amz-date:20250109T070429Z

host;x-amz-content-sha256;x-amz-date 71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73</CanonicalRequest><CanonicalRequestBytes>50 55 54 0a 2f 66 6f 6c 64 65 72 5f 31 2f 61 64 38 32 33 32 2e 74 78 74 0a 70 61 72 74 4e 75 6d 62 65 72 3d 31 26 75 70 6c 6f 61 64 49 64 3d 77 54 48 67 5a 64 64 61 79 34 39 51 58 48 71 36 4a 71 59 59 71 76 59 4d 59 66 79 79 44 37 6b 73 6d 30 52 4a 64 43 63 34 50 55 69 68 49 46 53 4b 47 66 62 73 35 54 49 41 4f 35 34 51 56 34 34 58 58 31 4f 33 36 6c 50 37 4d 76 59 35 39 6b 45 38 71 5f 56 44 7a 70 73 79 65 68 4d 4b 44 54 77 4f 30 32 73 6f 4c 39 37 36 34 6b 61 62 6e 4e 50 37 49 30 42 64 42 41 4e 41 64 79 4d 7a 58 6f 64 74 0a 68 6f 73 74 3a 65 73 70 33 32 2d 6d 75 6c 74 69 2e 73 33 2e 75 73 2d 65 61 73 74 2d 31 2e 61 6d 61 7a 6f 6e 61 77 73 2e 63 6f 6d 0a 78 2d 61 6d 7a 2d 63 6f 6e 74 65 6e 74 2d 73 68 61 32 35 36 3a 37 31 63 34 38 30 64 66 39 33 64 36 61 65 32 66 31 65 66 61 64 31 34 34 37 63 36 36 63 39 35 32 35 65 33 31 36 32 31 38 63 66 35 31 66 63 38 64 39 65 64 38 33 32 66 32 64 61 66 31 38 62 37 33 0a 78 2d 61 6d 7a 2d 64 61 74 65 3a 32 30 32 35 30 31 30 39 54 30 37 30 34 32 39 5a 0a 0a 68 6f 73 74 3b 78 2d 61 6d 7a 2d 63 6f 6e 74 65 6e 74 2d 73 68 61 32 35 36 3b 78 2d 61 6d 7a 2d 64 61 74 65 0a 37 31 63 34 38 30 64 66 39 33 64 36 61 65 32 66 31 65 66 61 64 31 34 34 37 63 36 36 63 39 35 32 35 65 33 31 36 32 31 38 63 66 35 31 66 63 38 64 39 65 64 38 33 32 66 32 64 61 66 31 38 62 37 33</CanonicalRequestBytes><RequestId>HG8RFYA2ETBP4YWG</RequestId><HostId>RgsGhui7GON4m3mOq6fcpN9ItSHXE1909eb+tjT1nkmDtExLL17H5S2eoEhLKRhdDmOORizNtXE=</HostId></Error> 0 .

i want to know how to make canonical request for upload part, also im sharing you my canonical request format for uploadpart:-

// Build the canonical request String url = "/folder_1/ad8232.txt?partNumber=" + String(partNumber) + "&uploadId=" + uploadId; String payload = "abcdefghijklmnopqrstuvwxyz"; String payloadHash = sha256(payload); String canonicalRequest = "PUT\n" + url + "\n\n" + "host:" + String(host) + "\n" + "x-amz-content-sha256:" + payloadHash + "\n" + "x-amz-date:" + date + "\n\n" + "host;x-amz-content-sha256;x-amz-date\n" + payloadHash;

asked 2 years ago223 views

1 Answer
0

Hello,

I understanding that you are trying to upload a file to S3, using a multipart upload process and you are looking for a canonical request. A canonical request, is literally, the same thing as the real request with small different syntax. After researching, I couldn't find instructions on how to build a similar request to your multi-part upload.

I'd recommend you to look at the API S3API and build the canonical request from there. Basically, you will need HTTP method (PUT), the bucket name, the key (object), host (s3.amazonaws.com), the string that identifies the part id (partnumber) and the headers.

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/upload-part.html

Hope that helps

AWS

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.