Skip to content

nodejs with Seaweed S3

Ignatiev Mikhail edited this page Sep 7, 2022 · 1 revision

Requirements & features

  • Use node@12.0.0+
  • Code with javascript or typescript
  • Seaweedfs with -s3 running at :8333

Installation

Install AWS S3 client

npm i @aws-sdk/client-s3

Client initialization

import { S3Client } from "@aws-sdk/client-s3"

const s3client = new S3Client({
  // specify endpoint with http://hostname:port
  endpoint: `http://127.0.0.1:8333`,
  // specify region since it is mandatory, but it will be ignored by seaweedfs
  region: `us-east-1`, 
  // force path style for compatibility reasons
  forcePathStyle: true,
  // credentials is mandatory and s3 authorization should be enabled with `s3.configure`
  credentials: {
    accessKeyId: `same as -accesskey`,
    secretAccessKey: `same as -secretkey`,
  }
})

Execute commands

// List buckets example
import { ListBucketsCommand } from "@aws-sdk/client-s3"
const response = await s3client.send(new ListBucketsCommand({}))
console.log(response.Buckets)

More commands: API Reference

Introduction

API

Configuration

Filer

Advanced Filer Configurations

Cloud Drive

AWS S3 API

AWS IAM

Machine Learning

HDFS

Replication and Backup

Messaging

Use Cases

Operations

Advanced

Security

Misc Use Case Examples

Clone this wiki locally