I want to upload images to a bucket using a pre-signed URL:
aws s3 presign s3://mybucket/something1.png --expires-in 7200
and just for testing other types:
aws s3 presign s3://mybucket/CV.pdf --expires-in 7200
note that the bucket has no policies in place right now.
I upload the files using this curl command:
curl "presign-url" --upload-file ~/Desktop/CV.pdf
curl "presign-url" --upload-file ~/Desktop/something1.png
in both cases:
as you can see, an extra “” is added at the end of they key and the type. I also considered using commands like:
curl -T ~/Desktop/something1.png -H "Content-Type: image/png" "presign-url"
but I get an error like this:
<?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>REDACTED</AWSAccessKeyId>
<StringToSign>AWS4-HMAC-SHA256
20240522T160714Z
20240522/eu-west-2/s3/aws4_request
REDACTED</StringToSign>
<SignatureProvided>REDACTED</SignatureProvided>
<StringToSignBytes>REDACTED</StringToSignBytes>
<CanonicalRequest>PUT
/hich.survey.images/something1.png
X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=REDACTED%2F20240522%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20240522T160714Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host
host:s3.eu-west-2.amazonaws.com
host
UNSIGNED-PAYLOAD</CanonicalRequest>
<CanonicalRequestBytes>REDACTED</CanonicalRequestBytes>
<RequestId>6QYT5HRK2RYE6PQF</RequestId>
<HostId>REDACTED</HostId>
</Error>