RustFS: Connecting Node.js to RustFS
This documentation is part of the Quick start guide guide. You can view the complete guide here: How to begin using RustFS for S3-compatible object storage.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use RustFS Object Storage platform designed for reliability and speed. Key benefits include:
- Unlimited data transfers with no hidden fees.
- Simple, predictable, and transparent pricing.
- A custom domain name secured with HTTPS (for example, https://object-storage.your-company.com).
- A web console and an admin API that you can restrict from the internet with a single click.
- One-click, seamless updates with no manual intervention required.
- High performance and security on private, dedicated infrastructure.
- Available in both 🇪🇺 Europe and 🇺🇸 USA regions.
Streamline your workflow and reduce setup time: you can deploy Stackhero's RustFS Object Storage hosting in just 5 minutes.
First, install the AWS SDK package for Node.js:
npm install @aws-sdk/client-s3
Below is an example to connect to RustFS using the AWS SDK:
const { S3Client, CreateBucketCommand, PutObjectCommand, GetObjectCommand } = require('@aws-sdk/client-s3');
const s3 = new S3Client({
endpoint: 'https://<XXXXXX>.stackhero-network.com',
region: 'us-east-1',
forcePathStyle: true,
credentials: {
accessKeyId: '<ROOT_ACCESS_KEY>',
secretAccessKey: '<ROOT_SECRET_KEY>'
}
});
(async () => {
// Create a bucket
await s3.send(new CreateBucketCommand({ Bucket: 'testbucket' }));
// Upload an object
await s3.send(new PutObjectCommand({ Bucket: 'testbucket', Key: 'testobject', Body: 'Hello from RustFS!' }));
// Download the object
const object = await s3.send(new GetObjectCommand({ Bucket: 'testbucket', Key: 'testobject' }));
console.log(await object.Body.transformToString());
})();
For more details about RustFS itself, see the official RustFS documentation.