RustFS: Connecting Python to RustFS

This documentation is part of the Getting started guide. View the full guide here: How to begin using RustFS for S3-compatible object storage.

👋 Welcome to the Stackhero documentation!

Stackhero provides a ready-to-use RustFS Object Storage platform designed for reliability and speed. Key advantages include:

  • Unlimited data transfers with no hidden costs.
  • 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 close to the internet in one click.
  • One-click, seamless updates that require no manual intervention.
  • 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 (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'.")