In aws-sdk v2
for javascript, we instantiate s3 client using:
var s3 = new AWS.S3({
accessKeyId: 'YOUR-ACCESSKEYID' ,
secretAccessKey: 'YOUR-SECRETACCESSKEY' ,
s3ForcePathStyle: true,
signatureVersion: 'v4'
});
Here you can see the signatureVersion
being able to be specified.
In v3
you instantiate the client using:
import { S3Client } from '@aws-sdk/client-s3';
credentials = {
accessKeyId: <ACCESS_KEY>,
secretAccessKey: <SECRET_ACCESS_KEY>
}
const client = new S3Client({
region: 'us-east-1',
credentials: credentials,
forcePathStyle: true,
})
The docs aren't very clear (and without an example) on how to do this. How would I specify the signatureVersion
for the client in this versin(v3) of the sdk?
I've just migrated from the old to new s3 client.
I previously had to specify signatureVersion: 'v4'
because of this issue (we had to upload files with whitespaces).
I have not had this issue since migrating, so I think it's safe to assume they use version 4 signatures by default.
And since they don't expose a signatureVersion
config option, I would say it's also safe to assume you can't use signature version 2 using the the new SDK.
--
[Edit] Check their docs: https://docs.aws.amazon.com/AmazonS3/latest/API/bucket-policy-s3-sigv4-conditions.html
"AWS" identifies Signature Version 2
"AWS4-HMAC-SHA256" identifies Signature Version 4
So you should be able to check the X-Amz-Algorithm
query param to make sure.