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; + } +}