Developer示例
s3cmd
将 s3cmd 连接到 RustFS,并从命令行执行基本对象操作。
s3cmd 是适用于 S3 兼容存储的命令行客户端。使用一个简短的配置文件即可将其指向您的 RustFS 端点。
安装
# macOS
brew install s3cmd
# Debian/Ubuntu
sudo apt install s3cmd
# or via pip
pip install s3cmd配置
创建 ~/.s3cfg。请将 localhost:9000 替换为您的服务器地址,并使用您自己的访问密钥。RustFS 使用路径样式寻址,因此请将存储桶主机设置为相同端点:
[default]
access_key = <your-access-key>
secret_key = <your-secret-key>
host_base = localhost:9000
host_bucket = localhost:9000
use_https = False
signature_v2 = False如果您已配置 TLS,请设置 use_https = True 并指向端口 9000。
验证
创建存储桶、上传文件并列出其内容:
s3cmd mb s3://my-bucket
s3cmd put /path/to/hello.txt s3://my-bucket/hello.txt
s3cmd ls s3://my-bucketupload: '/path/to/hello.txt' -> 's3://my-bucket/hello.txt' [1 of 1]
2026-07-16 10:00 12 s3://my-bucket/hello.txt