RustFS: Quick start guide
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.
RustFS is an object storage service that implements the Amazon S3 protocol. Any Amazon S3-compatible client can connect to RustFS and work with your buckets immediately. There is an Amazon S3 client library for nearly every programming language, including Ruby, Python, PHP, Go, Node.js, and Java.
You will find your service endpoint and root credentials in your Stackhero dashboard. All the examples below use three values:
- the endpoint:
https://<XXXXXX>.stackhero-network.com(or your own domain), - the access key:
<ROOT_ACCESS_KEY>, - the secret key:
<ROOT_SECRET_KEY>.
Use path-style addressing in your S3 client (
https://<endpoint>/<bucket>/<object>). Most SDKs refer to this option asforce_path_style,use_path_style_endpoint, orforcePathStyle. The examples below already have this option enabled.
Using the RustFS Console
Your Stackhero for RustFS instance includes the RustFS Console, a web interface to manage your buckets, objects, users, and their access policies. Its URL is displayed in your dashboard, under "WEB console". Log in with your root access key and root secret key.
The console is an option in your service configuration: you can disable it when you do not need it.
Using the RustFS CLI
The RustFS CLI, rc, is the command-line client for RustFS. It is especially useful for transferring large files and managing users and access policies from your terminal. Installation instructions for each platform are available on the RustFS CLI releases page.
The simplest way to try it is to use its Docker container:
-
Start the container:
docker run -it --rm --entrypoint=/bin/sh rustfs/rc:latest -
Inside the container, add your server (replace the placeholder values accordingly):
rc alias set stackhero https://<XXXXXX>.stackhero-network.com <ROOT_ACCESS_KEY> <ROOT_SECRET_KEY> -
Create a bucket named "test":
rc mb stackhero/test -
List your buckets:
rc ls stackhero
You can view the other commands by running rc --help. The MinIO client mc also works: RustFS supports its admin API.
Securing the admin API
The admin API (/rustfs/admin/ and /minio/admin/) is used by rc admin and mc admin to manage users, groups, policies, and access keys. It is open to the internet by default.
If you manage your users only from the RustFS Console, disable the option "Expose the admin API on the internet" in your service configuration. The S3 API remains available, and the RustFS Console retains its own access to the admin API.
Avoid using root credentials in your applications. Create a dedicated user, or an access key, with only the permissions required by the application.
Using the AWS CLI
Install the AWS CLI, then configure your credentials and the endpoint:
export AWS_ACCESS_KEY_ID=<ROOT_ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<ROOT_SECRET_KEY>
export AWS_DEFAULT_REGION=us-east-1
aws --endpoint-url https://<XXXXXX>.stackhero-network.com s3 mb s3://test
aws --endpoint-url https://<XXXXXX>.stackhero-network.com s3 cp ./photo.jpg s3://test/
aws --endpoint-url https://<XXXXXX>.stackhero-network.com s3 ls s3://test
Connecting Ruby to RustFS
First, install the AWS SDK gem:
gem install aws-sdk-s3
Here is a simple example to interact with RustFS using the AWS SDK in Ruby:
require 'aws-sdk-s3'
s3 = Aws::S3::Client.new(
endpoint: 'https://<XXXXXX>.stackhero-network.com',
access_key_id: '<ROOT_ACCESS_KEY>',
secret_access_key: '<ROOT_SECRET_KEY>',
force_path_style: true,
region: 'us-east-1'
)
# Create a bucket
s3.create_bucket(bucket: 'testbucket')
# Upload an object
s3.put_object(
bucket: 'testbucket',
key: 'testobject',
body: 'Hello from RustFS!',
content_type: 'text/plain'
)
# Download the object to a local file
s3.get_object(
bucket: 'testbucket',
key: 'testobject',
response_target: 'download_testobject'
)
puts "Downloaded 'testobject' as 'download_testobject'."
Connecting Python to RustFS
First, install the AWS SDK package (boto3):
pip install boto3
pip freeze > requirements.txt
The following example connects to RustFS using boto3:
#!/usr/bin/env python
import boto3
from botocore.client import Config
s3 = boto3.resource('s3',
endpoint_url='https://<XXXXXX>.stackhero-network.com',
aws_access_key_id='<ROOT_ACCESS_KEY>',
aws_secret_access_key='<ROOT_SECRET_KEY>',
config=Config(signature_version='s3v4', s3={'addressing_style': 'path'}),
region_name='us-east-1')
# Create the bucket 'songs'
s3.create_bucket(Bucket='songs')
# Upload a local file '/home/john/piano.mp3' to the bucket 'songs' with the object name 'piano.mp3'
s3.Bucket('songs').upload_file('/home/john/piano.mp3', 'piano.mp3')
# Download the object 'piano.mp3' from the bucket 'songs' and save it locally as '/tmp/classical.mp3'
s3.Bucket('songs').download_file('piano.mp3', '/tmp/classical.mp3')
print("'piano.mp3' downloaded as 'classical.mp3'.")
Connecting PHP to RustFS
First, install the AWS SDK for PHP:
composer require aws/aws-sdk-php
The example below connects to RustFS from PHP using the AWS SDK:
<?php
require 'vendor/autoload.php';
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'endpoint' => 'https://<XXXXXX>.stackhero-network.com',
'use_path_style_endpoint' => true,
'credentials' => [
'key' => '<ROOT_ACCESS_KEY>',
'secret' => '<ROOT_SECRET_KEY>'
],
]);
// Create a bucket
$s3->createBucket([ 'Bucket' => 'testbucket' ]);
// Upload an object
$s3->putObject([
'Bucket' => 'testbucket',
'Key' => 'testkey',
'Body' => 'Hello from RustFS!'
]);
// Download the object and print its content
$retrieve = $s3->getObject([
'Bucket' => 'testbucket',
'Key' => 'testkey'
]);
echo $retrieve['Body'];
Connecting Go to RustFS
First, install the AWS SDK packages for Go:
go get github.com/aws/aws-sdk-go-v2/aws
go get github.com/aws/aws-sdk-go-v2/credentials
go get github.com/aws/aws-sdk-go-v2/service/s3
Below is an example to connect to RustFS from Go using the AWS SDK:
package main
import (
"context"
"fmt"
"io"
"log"
"strings"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
func main() {
ctx := context.Background()
client := s3.New(s3.Options{
BaseEndpoint: aws.String("https://<XXXXXX>.stackhero-network.com"),
Region: "us-east-1",
Credentials: credentials.NewStaticCredentialsProvider("<ROOT_ACCESS_KEY>", "<ROOT_SECRET_KEY>", ""),
UsePathStyle: true,
})
bucket := aws.String("newbucket")
key := aws.String("testobject")
// Create a bucket
if _, err := client.CreateBucket(ctx, &s3.CreateBucketInput{Bucket: bucket}); err != nil {
log.Fatal(err)
}
// Upload an object
_, err := client.PutObject(ctx, &s3.PutObjectInput{
Bucket: bucket,
Key: key,
Body: strings.NewReader("Hello from RustFS!"),
})
if err != nil {
log.Fatal(err)
}
// Download the object
object, err := client.GetObject(ctx, &s3.GetObjectInput{Bucket: bucket, Key: key})
if err != nil {
log.Fatal(err)
}
defer object.Body.Close()
content, err := io.ReadAll(object.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(content))
}
Connecting Node.js to RustFS
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.