From 39df7c49c74cfe2dcf609c9eb662e21548c076c5 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 25 Oct 2026 23:48:05 +0800 Subject: [PATCH] docs(infra): 补充 RustFS S3 接入说明与 MySQL 示例 --- sql/mysql/ruoyi-vue-pro.sql | 1 + yudao-module-infra/pom.xml | 2 +- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java | 6 +++--- yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java | 6 ++++++ yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 687e1ac..6657d42 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -316,6 +316,7 @@ INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `c INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (30, 'SFTP 存储(示例)', 12, '', b'0', '{\"@class\":\"cn.iocoder.yudao.module.infra.framework.file.core.client.sftp.SftpFileClientConfig\",\"basePath\":\"/upload\",\"domain\":\"http://127.0.0.1:48080\",\"host\":\"127.0.0.1\",\"port\":2222,\"username\":\"foo\",\"password\":\"pass\"}', '1', '2025-05-02 16:34:10', '1', '2026-07-02 15:35:07', b'0'); INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (34, '七牛云存储【私有】(示例)', 20, '请换成你自己的密钥!!!', b'0', '{\"@class\":\"cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"s3.cn-south-1.qiniucs.com\",\"domain\":\"http://t151glocd.hn-bkt.clouddn.com\",\"bucket\":\"ruoyi-vue-pro-private\",\"accessKey\":\"3TvrJ70gl2Gt6IBe7_IZT1F6i_k0iMuRtyEv4EyS\",\"accessSecret\":\"wd0tbVBYlp0S-ihA8Qg2hPLncoP83wyrIq24OZuY\",\"enablePathStyleAccess\":false,\"enablePublicAccess\":false}', '1', '2025-08-17 21:22:00', '1', '2026-07-02 15:35:07', b'0'); INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (35, '1', 20, '1', b'0', '{\"@class\":\"cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"http://www.baidu.com\",\"domain\":\"http://www.xxx.com\",\"bucket\":\"1\",\"accessKey\":\"2\",\"accessSecret\":\"3\",\"enablePathStyleAccess\":false,\"enablePublicAccess\":false,\"region\":\"1\"}', '1', '2025-10-02 14:32:12', '1', '2026-07-02 15:35:07', b'0'); +INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `config`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (36, 'RustFS 存储(示例)', 20, '请先部署 RustFS、创建存储桶,并替换成你自己的地址和密钥!!!', b'0', '{\"@class\":\"cn.iocoder.yudao.module.infra.framework.file.core.client.s3.S3FileClientConfig\",\"endpoint\":\"http://127.0.0.1:9000\",\"domain\":\"http://127.0.0.1:9000/ruoyi-vue-pro\",\"bucket\":\"ruoyi-vue-pro\",\"accessKey\":\"your-access-key\",\"accessSecret\":\"your-secret-key\",\"enablePathStyleAccess\":true,\"enablePublicAccess\":false,\"region\":\"us-east-1\"}', '1', '2026-10-25 23:01:12', '1', '2026-10-25 23:01:12', b'0'); COMMIT; -- ---------------------------- diff --git a/yudao-module-infra/pom.xml b/yudao-module-infra/pom.xml index bd0e6c7..99b9b1c 100644 --- a/yudao-module-infra/pom.xml +++ b/yudao-module-infra/pom.xml @@ -104,7 +104,7 @@ com.github.mwiede jsch - + software.amazon.awssdk s3 diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java index 34928d6..8ad38ee 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java @@ -26,7 +26,7 @@ import java.net.URL; import java.time.Duration; /** - * 基于 S3 协议的文件客户端,实现 MinIO、阿里云、腾讯云、七牛云、华为云等云服务 + * 基于 S3 协议的文件客户端,实现 MinIO、RustFS、阿里云、腾讯云、七牛云、华为云等云服务 * * @author 芋道源码 */ @@ -156,7 +156,7 @@ public class S3FileClient extends AbstractFileClient { * @return Domain 地址 */ private String buildDomain() { - // 如果已经是 http 或者 https,则不进行拼接.主要适配 MinIO + // 如果已经是 http 或者 https,则不进行拼接.主要适配 MinIO、RustFS if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) { return StrUtil.format("{}/{}", config.getEndpoint(), config.getBucket()); } @@ -265,7 +265,7 @@ public class S3FileClient extends AbstractFileClient { } } - // 3.4 其他情况(MinIO、七牛云等)使用默认值 + // 3.4 其他情况(MinIO、RustFS、七牛云等)使用默认值 return "us-east-1"; } diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java index 3300a3e..a3f093a 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java @@ -30,6 +30,7 @@ public class S3FileClientConfig implements FileClientConfig { * 4. 七牛云:https://developer.qiniu.com/kodo/4088/s3-access-domainname * 5. 华为云:https://console.huaweicloud.com/apiexplorer/#/endpoint/OBS * 6. 火山云:https://www.volcengine.com/docs/6349/107356 + * 7. RustFS:https://docs.rustfs.com/en/administration/protocols/s3/ 。例如说,http://127.0.0.1:9000(S3 API 端口,不是 9001 控制台端口) */ @NotNull(message = "endpoint 不能为空") private String endpoint; @@ -41,6 +42,7 @@ public class S3FileClientConfig implements FileClientConfig { * 4. 七牛云:https://developer.qiniu.com/kodo/8556/set-the-custom-source-domain-name * 5. 华为云:https://support.huaweicloud.com/usermanual-obs/obs_03_0032.html * 6. 火山云:https://www.volcengine.com/docs/6349/128983 + * 7. RustFS:不填写时为 endpoint/bucket;PathStyle 访问时需带上 /bucket,例如说 http://127.0.0.1:9000/ruoyi-vue-pro,且需前端可访问 */ @URL(message = "domain 必须是 URL 格式") private String domain; @@ -58,6 +60,7 @@ public class S3FileClientConfig implements FileClientConfig { * 4. 七牛云:https://portal.qiniu.com/user/key * 5. 华为云:https://support.huaweicloud.com/qs-obs/obs_qs_0005.html * 6. 火山云:https://console.volcengine.com/iam/keymanage/ + * 7. RustFS:https://docs.rustfs.com/en/installation/container/docker/ 。例如说,启动时配置的 RUSTFS_ACCESS_KEY */ @NotNull(message = "accessKey 不能为空") private String accessKey; @@ -69,6 +72,8 @@ public class S3FileClientConfig implements FileClientConfig { /** * 是否启用 PathStyle 访问 + * + * MinIO、RustFS:建议 true。其中,RustFS 默认使用 PathStyle,虚拟主机风格需服务端额外配置 RUSTFS_SERVER_DOMAINS */ @NotNull(message = "enablePathStyleAccess 不能为空") private Boolean enablePathStyleAccess; @@ -91,6 +96,7 @@ public class S3FileClientConfig implements FileClientConfig { * 5. 七牛云:不需要填写,会自动识别 * 6. 华为云:不需要填写,会自动识别 * 7. 火山云:不需要填写,会自动识别 + * 8. RustFS:需与服务端的 RUSTFS_REGION 一致,默认 us-east-1;不填写时,也使用 us-east-1 */ private String region; diff --git a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java index 04b6867..0af2935 100644 --- a/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java +++ b/yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java @@ -5,7 +5,7 @@ * 2. ftp:FTP 服务器 * 3. sftp:SFTP 服务器 * 4. db:数据库 - * 5. s3:支持 S3 协议的云存储服务,例如说 MinIO、阿里云、华为云、腾讯云、七牛云等等 + * 5. s3:支持 S3 协议的云存储服务,例如说 MinIO、RustFS、阿里云、华为云、腾讯云、七牛云等等 * * @author 芋道源码 */ -- libgit2 0.21.4