I can generate the presigned url following the steps as described in this section, so I wanted to test uploading a specific image marble.jpg
and I tried to use postman
to test the upload. So, I copied the presigned url and hit the endpoint
with a PUT
request, and I got this 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>
<Key>records/marble_cave.jpg</Key>
<BucketName>bucket</BucketName>
<Resource>/bucket/records/marble.jpg</Resource>
<RequestId>17E3999B521ABB65</RequestId>
<HostId>50abb07a-2ad0-4948-96e0-23403f661cba</HostId>
</Error>
The following resources are setup:
- I'm using the
min.io
server to test this locally. - I'm using
aws-sdk
version 3 of the nodejs sdk for aws - I've triple checked my credentials, simple
minio
creds with no special characters also, I'm definitely making aPUT
request.
So, The question is:
How to set the
signatureVersion
using the new javascript aws sdk version 3. ( ThegetSignedUrl
is used to generate presigned url in v3 of the sdk,import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
)what causes might be there such that this error is occuring?
The code I use for presigned url generation is:
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
const s3Client = new S3Client({
region: 'us-east-1',
credentials: {
accessKeyId: 'minioadmin',
secretAccessKey: 'minioadmin',
},
endpoint: http://172.21.0.2:9000,
forcePathStyle: true,
});
const bucketParams = {
Bucket: 'myBucket',
Key: `marbles.jpg`,
};
const command = new PutObjectCommand(bucketParams);
const signedUrl = await getSignedUrl(s3Client, command, {
expiresIn: 10000,
})