I implemented uploading file in Amazon s3 bucket like below and it works fine:
const S3 = require('aws-sdk/clients/s3');
const AWS = require('aws-sdk');
const accessKeyId = 'AKIAYVXDX*******';
const secretAccessKey = 'gxZpdSDnOfpM*****************';
const s3 = new S3({
region: 'us-east-1',
accessKeyId,
secretAccessKey
});
s3.putObject({
Body: 'Hello World',
Bucket: "dev-amazon",
Key: 'hello.txt'
}
, (err, data) => {
if (err) {
console.log(err);
}
});
And I need to implement uploading file in Wasabi bucket.
I tried like below:
const S3 = require('aws-sdk/clients/s3');
const AWS = require('aws-sdk');
const wasabiEndpoint = new AWS.Endpoint('s3.wasabisys.com');
const accessKeyId = 'PEIL4DYOY*******';
const secretAccessKey = 'D4jIz3tjJw*****************';
const s3 = new S3({
endpoint: wasabiEndpoint,
region: 'us-east-2',
accessKeyId,
secretAccessKey
});
s3.putObject({
Body: 'Hello World',
Bucket: "dev-wasabi",
Key: 'hello.txt'
}
, (err, data) => {
if (err) {
console.log(err);
}
});
And the result of `console.log(err) is:
err {"message":"The request signature we calculated does not match the signature you provided. Check your key and signing method.","code":"SignatureDoesNotMatch","region":null,"time":"2019-10-30T09:39:19.072Z","requestId":null,"statusCode":403,"retryable":false,"retryDelay":64.72166771381391}
Console error in devtools:
PUT https://dev-wasabi.s3.us-east-2.wasabisys.com/5efa9b286821fab7df3ece8dc3d6687ed32 403 (Forbidden)
What is wrong in my codes?
I found the reason of this issue myself.
wasabiEndpoint
was wrong.
It should be
const wasabiEndpoint = new AWS.Endpoint('s3.us-east-2.wasabisys.com ');
According to docs, service URLs should be different based on regions.
Wasabi US East 1 (N. Virginia): s3.wasabisys.com or s3.us-east-1.wasabisys.com
Wasabi US East 2 (N. Virginia): s3.us-east-2.wasabisys.com
Wasabi US West 1 (Oregon): s3.us-west-1.wasabisys.com
Wasabi EU Central 1 (Amsterdam): s3.eu-central-1.wasabisys.com
I will be very grateful if this helps someone. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With