I'm trying to generate a presigned URL for an S3 bucket on AWS to upload files to like this:
$ aws s3 presign s3://mybucket/somefolder/
Then I use that URL to upload a file:
$ curl "https://mybucket.s3.amazonaws.com/somefolder/?AWSAccessKeyId=***&Signature=***&Expires=***" --upload-file "./file"
But then it prints out an XML error:
<?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>PUT
************
/mybucket/somefolder/</StringToSign>
<SignatureProvided>**************</SignatureProvided>
<StringToSignBytes>**************</StringToSignBytes>
<RequestId>************</RequestId>
<HostId>************</HostId>
</Error>
What am I doing wrong?
[UPDATE]
OK, so I have to specify the object name in the presigned URL. So I did but I'm still facing the same error message:
$ aws s3 presign s3://mybucket/someobject
And then:
$ curl "https://mybucket.s3.amazonaws.com/someobject?AWSAccessKeyId=***&Signature=***&Expires=***" --upload-file "./file"
And I'll get the exact same error as before. To make sure that it's not a permission problem, I tested it like this:
$ aws s3 cp ./file s://mybucket/
And the file was copied! Any suggestions?
[UPDATE]
I even tested with an object which actually exists in the bucket and managed to successfully download it. But still I cannot write to the object, only read.