How to use JavaScript aws-sdk for Scaleway S3 Object Storage


Few month ago I was showing up how to put an object into Scaleway Object Storage. At that time it was the second time I was playing with their solution, and since I was using a very small part of there S3 based API, I did it the easy way with aws4 signing method and a simple request. However you may want to do more with Scaleway S3 Object Storage, I'll show you how easily you'll be able to set up an external provider as a config and use latest aws-sdk with it, and then unleash the full potential of a S3 based Object Storage Solution.

My image

What are the API currently supported

What's being cool with Scaleway S3 Object Storage is that they based their Object Storage solution on a now called "a standard" S3, which means whether you deal with AWS or Scaleway you'll be able to use the exact same SDK and programmatic logic. You'll be even able to use a hybrid solution if you need it. Scaleway teams are working hard to support all the feature, but you need to know that the vast majority are supported but not all of them.
You can check this out on there S3 Object Storage API development status page:

S3 Object Storage API
This page shows how to use the S3 Object Storage API
S3 Object Storage API development status

How to use JavaScript aws-sdk

  1. Setup your JavaScript/Node.js project
  2. Install aws-sdk with yarn add aws-sdk or npm install aws-sdk
  3. Config your AWS instance
const config = require('./config');
const AWS = require("aws-sdk");

const awsConfig = new AWS.Config({
  accessKeyId: config.accessKeyId,
  secretAccessKey: config.secretAccessKey,
  region: config.region,
  s3BucketEndpoint: true,
  endpoint: config.endpoint

const s3 = new AWS.S3(awsConfig);

Where you have a config.json file alongside with your credentials or provide them with and .env file or the way you want

  "accessKeyId": "ACCES_KEY_ID",
  "secretAccessKey": "SECRET_ACCESS_KEY",
  "region": "REGION",
  "bucketName": "BUCKET_NAME",
  "endpoint": "BUCKET_ENDPOINT_URL"

While doing this you'll be able to use the following aws-sdk functions

  • s3.putObject
  • s3.deleteObject
  • s3.uploadObject

And so on ..

Full documentation S3 aws-sdk:

NPM aws-sdk:

AWS SDK for JavaScript

That's sit for today, happy coding, enjoy 🎉