Developer示例

rclone

将 rclone 连接到 RustFS,并执行基本对象操作。

rclone 是一个用于在云存储中同步文件的命令行程序,支持 RustFS 实现的 S3 协议。

安装

curl https://rclone.org/install.sh | sudo bash

也可以参阅官方安装指南

配置

~/.config/rclone/rclone.conf 中添加远程存储。请将 http://localhost:9000 替换为您的服务器地址,并使用您自己的访问密钥。RustFS 使用路径样式寻址,因此必须设置 force_path_style = true

~/.config/rclone/rclone.conf
[rustfs]
type = s3
provider = Other
access_key_id = <your-access-key>
secret_access_key = <your-secret-key>
endpoint = http://localhost:9000
region = us-east-1
force_path_style = true

验证

创建存储桶:

rclone mkdir rustfs:my-bucket

上传文件:

rclone copy /path/to/hello.txt rustfs:my-bucket

列出存储桶及其内容:

rclone lsd rustfs:
rclone ls rustfs:my-bucket
          -1 2026-07-15 10:30:00        -1 my-bucket
       12 hello.txt

后续步骤

使用 S3 SDK 构建与 RustFS 对接的应用程序,或使用 rc 管理对象。

本页目录