MigraDrive Docs Open Console

SDK Examples

These snippets connect to MigraDrive using the S3-compatible endpoint.

Node.js (AWS SDK v3)

Install packages:

npm i @aws-sdk/client-s3

Example: list buckets

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

const s3 = new S3Client({
  region: process.env.MIGRADRIVE_REGION ?? "us-east-1",
  endpoint: process.env.MIGRADRIVE_ENDPOINT ?? "https://s3.migradrive.com",
  forcePathStyle: true,
  credentials: {
    accessKeyId: process.env.MIGRADRIVE_ACCESS_KEY,
    secretAccessKey: process.env.MIGRADRIVE_SECRET_KEY,
  },
});

const run = async () => {
  const out = await s3.send(new ListBucketsCommand({}));
  console.log(out.Buckets?.map((b) => b.Name));
};

run().catch(console.error);

Python (boto3)

Install:

pip install boto3

Example: list buckets

import os
import boto3

s3 = boto3.client(
  "s3",
  endpoint_url=os.environ.get("MIGRADRIVE_ENDPOINT", "https://s3.migradrive.com"),
  aws_access_key_id=os.environ["MIGRADRIVE_ACCESS_KEY"],
  aws_secret_access_key=os.environ["MIGRADRIVE_SECRET_KEY"],
  region_name=os.environ.get("MIGRADRIVE_REGION", "us-east-1"),
)

resp = s3.list_buckets()
print([b["Name"] for b in resp.get("Buckets", [])])

If your app needs virtual-host style buckets, you may need additional DNS patterns. Path-style is typically simplest.