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');
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 403 (Forbidden)
What is wrong in my codes?
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?
Share Improve this question edited Jun 6, 2020 at 6:54 Diamond asked Oct 30, 2019 at 9:51 DiamondDiamond 3,4284 gold badges20 silver badges41 bronze badges2 Answers
Reset to default 19After some research, I found that 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
Will be more than happy if this can help someone. ;)
When using the @aws-sdk/client-s3 package, the S3 client only needs the Wasabi endpoint defined. The following will create the S3 client w/ the correct endpoint:
const client = new S3Client({
credentials: {
accessKeyId: "<wasabi-access-key-id>",
secretAccessKey: "<wasabi-secret-key>"
},
endpoint: {
url: "https://s3.wasabisys.com"
}
})
From here, putting an object is exactly the same as a standard AWS S3 bucket. Ex:
await client.send(new PutObjectCommand({
Bucket: "bucket-name",
Key: "object-key",
Body: <whatever is being put>
})
With the basic import statement being:
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"