Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pages/sdk/auto-drive/s3_layer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,41 @@ Auto Drive itself uses these helpers, so you get the same delimiter folding, pag
- Network timeouts may be longer than traditional S3; configure your SDK accordingly

This S3 layer provides a familiar interface while leveraging the benefits of decentralized storage, making it easy to migrate existing S3-based applications — and S3-compatible tooling like rclone and the AWS CLI — to Auto Drive.

---

## AWS S3 Migration Quickstart (Node.js Example)

Below is a clean, minimal implementation showing how to route an existing AWS S3 SDK workflow to the Auto Drive S3 API layer using the official `@aws-sdk/client-s3` package.

```javascript
const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");

// Initialize the S3 Client pointed at the Auto Drive Endpoint
const autoDriveClient = new S3Client({
region: "us-east-1",
endpoint: "[https://public.auto-drive.autonomys.xyz/s3](https://public.auto-drive.autonomys.xyz/s3)", // Official Auto Drive S3 gateway URL
credentials: {
accessKeyId: "ANY_ANY_PLACEHOLDER_STRING", // Can be set to any arbitrary value
secretAccessKey: "ANY_ANY_PLACEHOLDER_STRING",
},
forcePathStyle: true,
});

async function uploadToPermanentStorage(bucketName, fileKey, fileBuffer) {
const command = new PutObjectCommand({
Bucket: bucketName,
Key: fileKey,
Body: fileBuffer,
});

try {
const response = await autoDriveClient.send(command);
console.log("🔒 Data written permanently to Autonomys!");
console.log("Decentralized ETag (CID Mapping):", response.ETag);
return response;
} catch (error) {
console.error("Migration Upload Error:", error);
throw error;
}
}