From e3ae245cfca1f0639c639b0bf757f7bd154787c3 Mon Sep 17 00:00:00 2001 From: Emmanuel Chibuzor <81642211+EmmanuelMarv@users.noreply.github.com> Date: Fri, 5 Jun 2026 09:18:04 +0100 Subject: [PATCH] docs: add modular Node.js AWS S3 migration client implementation This contribution addresses the feedback provided in Pull Request #952 regarding the relocation of the S3 migration guide. Key Updates: - Relocated the S3 migration documentation to the Developer Hub repository as requested. - Integrated a production-ready Node.js implementation example using the official @aws-sdk/client-s3 library. - Updated the client configuration to utilize the correct public gateway endpoint (https://public.auto-drive.autonomys.xyz/s3). - Implemented non-sensitive placeholder strings for credentials to align with documentation security standards. By providing a concrete code snippet, this guide now offers a more direct 'developer-first' path for migrating existing S3 workflows to the Autonomys DSN. --- pages/sdk/auto-drive/s3_layer.mdx | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pages/sdk/auto-drive/s3_layer.mdx b/pages/sdk/auto-drive/s3_layer.mdx index e697456..59d9fb4 100644 --- a/pages/sdk/auto-drive/s3_layer.mdx +++ b/pages/sdk/auto-drive/s3_layer.mdx @@ -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; + } +}