How do I use AWS SDK for JavaScript with Wasabi?

AWS SDK for JavaScript is certified for use with Wasabi. As a FYI, Wasabi uses this SDK to help power the Wasabi Management Console.   

To help our customers use this SDK with Wasabi, we have provided a sample.js below. This sample shows how to set the credentials, create a bucket, and upload a file. Some other examples can be found in the AWS documentation.   

* Copyright 2013. Amazon Web Services, Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and
* limitations under the License.

// Load the SDK and UUID
var AWS = require('aws-sdk');
var uuid = require('node-uuid');

// Create an S3 client
var credentials = new AWS.SharedIniFileCredentials({profile: 'wasabi'});
AWS.config.credentials = credentials;
var ep = new AWS.Endpoint('');
var s3 = new AWS.S3({endpoint: ep});

// Create a bucket and upload something into it
var bucketName = 'node-sdk-sample-' + uuid.v4();
var keyName = 'hello_world.txt';

s3.createBucket({Bucket: bucketName}, function() {
var params = {Bucket: bucketName, Key: keyName, Body: 'Hello World!'};
s3.putObject(params, function(err, data) {
if (err)
console.log("Successfully uploaded data to " + bucketName + "/" + keyName);

Content of the config.json

wasabi@vm:~/aws-nodejs-sample$ more config.json
"accessKeyId": your_wasabi_access_key, "secretAccessKey": your_wasabi_secret_key, "region": "us-east-1" }

You can also have the credentials added to the ~/.aws/credentials as a separate profile

aws_access_key_id = your_wasabi_access_key
aws_secret_access_key = your_wasabi_secret_key
In this case you wont need the following 2 lines in the script above

var credentials = new AWS.SharedIniFileCredentials({profile: 'wasabi'});
AWS.config.credentials = credentials;
Then run the same script as follows.

wasabi@vm:~/aws-nodejs-sample$ AWS_PROFILE=wasabi node sample.js
Successfully uploaded data to node-sdk-sample-38cb5413-29c2-46f5-ab2d-4ac4d553f929/hello_world.txt

Note that this example discusses the use of Wasabi's us-east-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this article

Have more questions? Submit a request