Commit 39df7c49c74cfe2dcf609c9eb662e21548c076c5
1 parent
058223f3
docs(infra): 补充 RustFS S3 接入说明与 MySQL 示例
补充文件客户端的 RustFS 配置注释,沿用现有 S3 存储类型。 新增非主的 RustFS MySQL 示例配置,使用占位密钥和私有桶访问。
Showing
5 changed files
with
12 additions
and
5 deletions
sql/mysql/ruoyi-vue-pro.sql
| @@ -316,6 +316,7 @@ INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `c | @@ -316,6 +316,7 @@ INSERT INTO `infra_file_config` (`id`, `name`, `storage`, `remark`, `master`, `c | ||
| 316 | 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'); | 316 | 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'); |
| 317 | 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'); | 317 | 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'); |
| 318 | 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'); | 318 | 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'); |
| 319 | +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'); | ||
| 319 | COMMIT; | 320 | COMMIT; |
| 320 | 321 | ||
| 321 | -- ---------------------------- | 322 | -- ---------------------------- |
yudao-module-infra/pom.xml
| @@ -104,7 +104,7 @@ | @@ -104,7 +104,7 @@ | ||
| 104 | <groupId>com.github.mwiede</groupId> | 104 | <groupId>com.github.mwiede</groupId> |
| 105 | <artifactId>jsch</artifactId> <!-- 文件客户端:解决 sftp 连接 --> | 105 | <artifactId>jsch</artifactId> <!-- 文件客户端:解决 sftp 连接 --> |
| 106 | </dependency> | 106 | </dependency> |
| 107 | - <!-- 文件客户端:解决阿里云、腾讯云、minio 等 S3 连接 --> | 107 | + <!-- 文件客户端:解决阿里云、腾讯云、minio、rustfs 等 S3 连接 --> |
| 108 | <dependency> | 108 | <dependency> |
| 109 | <groupId>software.amazon.awssdk</groupId> | 109 | <groupId>software.amazon.awssdk</groupId> |
| 110 | <artifactId>s3</artifactId> | 110 | <artifactId>s3</artifactId> |
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; | @@ -26,7 +26,7 @@ import java.net.URL; | ||
| 26 | import java.time.Duration; | 26 | import java.time.Duration; |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | - * 基于 S3 协议的文件客户端,实现 MinIO、阿里云、腾讯云、七牛云、华为云等云服务 | 29 | + * 基于 S3 协议的文件客户端,实现 MinIO、RustFS、阿里云、腾讯云、七牛云、华为云等云服务 |
| 30 | * | 30 | * |
| 31 | * @author 芋道源码 | 31 | * @author 芋道源码 |
| 32 | */ | 32 | */ |
| @@ -156,7 +156,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { | @@ -156,7 +156,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { | ||
| 156 | * @return Domain 地址 | 156 | * @return Domain 地址 |
| 157 | */ | 157 | */ |
| 158 | private String buildDomain() { | 158 | private String buildDomain() { |
| 159 | - // 如果已经是 http 或者 https,则不进行拼接.主要适配 MinIO | 159 | + // 如果已经是 http 或者 https,则不进行拼接.主要适配 MinIO、RustFS |
| 160 | if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) { | 160 | if (HttpUtil.isHttp(config.getEndpoint()) || HttpUtil.isHttps(config.getEndpoint())) { |
| 161 | return StrUtil.format("{}/{}", config.getEndpoint(), config.getBucket()); | 161 | return StrUtil.format("{}/{}", config.getEndpoint(), config.getBucket()); |
| 162 | } | 162 | } |
| @@ -265,7 +265,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { | @@ -265,7 +265,7 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { | ||
| 265 | } | 265 | } |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | - // 3.4 其他情况(MinIO、七牛云等)使用默认值 | 268 | + // 3.4 其他情况(MinIO、RustFS、七牛云等)使用默认值 |
| 269 | return "us-east-1"; | 269 | return "us-east-1"; |
| 270 | } | 270 | } |
| 271 | 271 |
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 { | @@ -30,6 +30,7 @@ public class S3FileClientConfig implements FileClientConfig { | ||
| 30 | * 4. 七牛云:https://developer.qiniu.com/kodo/4088/s3-access-domainname | 30 | * 4. 七牛云:https://developer.qiniu.com/kodo/4088/s3-access-domainname |
| 31 | * 5. 华为云:https://console.huaweicloud.com/apiexplorer/#/endpoint/OBS | 31 | * 5. 华为云:https://console.huaweicloud.com/apiexplorer/#/endpoint/OBS |
| 32 | * 6. 火山云:https://www.volcengine.com/docs/6349/107356 | 32 | * 6. 火山云:https://www.volcengine.com/docs/6349/107356 |
| 33 | + * 7. RustFS:https://docs.rustfs.com/en/administration/protocols/s3/ 。例如说,http://127.0.0.1:9000(S3 API 端口,不是 9001 控制台端口) | ||
| 33 | */ | 34 | */ |
| 34 | @NotNull(message = "endpoint 不能为空") | 35 | @NotNull(message = "endpoint 不能为空") |
| 35 | private String endpoint; | 36 | private String endpoint; |
| @@ -41,6 +42,7 @@ public class S3FileClientConfig implements FileClientConfig { | @@ -41,6 +42,7 @@ public class S3FileClientConfig implements FileClientConfig { | ||
| 41 | * 4. 七牛云:https://developer.qiniu.com/kodo/8556/set-the-custom-source-domain-name | 42 | * 4. 七牛云:https://developer.qiniu.com/kodo/8556/set-the-custom-source-domain-name |
| 42 | * 5. 华为云:https://support.huaweicloud.com/usermanual-obs/obs_03_0032.html | 43 | * 5. 华为云:https://support.huaweicloud.com/usermanual-obs/obs_03_0032.html |
| 43 | * 6. 火山云:https://www.volcengine.com/docs/6349/128983 | 44 | * 6. 火山云:https://www.volcengine.com/docs/6349/128983 |
| 45 | + * 7. RustFS:不填写时为 endpoint/bucket;PathStyle 访问时需带上 /bucket,例如说 http://127.0.0.1:9000/ruoyi-vue-pro,且需前端可访问 | ||
| 44 | */ | 46 | */ |
| 45 | @URL(message = "domain 必须是 URL 格式") | 47 | @URL(message = "domain 必须是 URL 格式") |
| 46 | private String domain; | 48 | private String domain; |
| @@ -58,6 +60,7 @@ public class S3FileClientConfig implements FileClientConfig { | @@ -58,6 +60,7 @@ public class S3FileClientConfig implements FileClientConfig { | ||
| 58 | * 4. 七牛云:https://portal.qiniu.com/user/key | 60 | * 4. 七牛云:https://portal.qiniu.com/user/key |
| 59 | * 5. 华为云:https://support.huaweicloud.com/qs-obs/obs_qs_0005.html | 61 | * 5. 华为云:https://support.huaweicloud.com/qs-obs/obs_qs_0005.html |
| 60 | * 6. 火山云:https://console.volcengine.com/iam/keymanage/ | 62 | * 6. 火山云:https://console.volcengine.com/iam/keymanage/ |
| 63 | + * 7. RustFS:https://docs.rustfs.com/en/installation/container/docker/ 。例如说,启动时配置的 RUSTFS_ACCESS_KEY | ||
| 61 | */ | 64 | */ |
| 62 | @NotNull(message = "accessKey 不能为空") | 65 | @NotNull(message = "accessKey 不能为空") |
| 63 | private String accessKey; | 66 | private String accessKey; |
| @@ -69,6 +72,8 @@ public class S3FileClientConfig implements FileClientConfig { | @@ -69,6 +72,8 @@ public class S3FileClientConfig implements FileClientConfig { | ||
| 69 | 72 | ||
| 70 | /** | 73 | /** |
| 71 | * 是否启用 PathStyle 访问 | 74 | * 是否启用 PathStyle 访问 |
| 75 | + * | ||
| 76 | + * MinIO、RustFS:建议 true。其中,RustFS 默认使用 PathStyle,虚拟主机风格需服务端额外配置 RUSTFS_SERVER_DOMAINS | ||
| 72 | */ | 77 | */ |
| 73 | @NotNull(message = "enablePathStyleAccess 不能为空") | 78 | @NotNull(message = "enablePathStyleAccess 不能为空") |
| 74 | private Boolean enablePathStyleAccess; | 79 | private Boolean enablePathStyleAccess; |
| @@ -91,6 +96,7 @@ public class S3FileClientConfig implements FileClientConfig { | @@ -91,6 +96,7 @@ public class S3FileClientConfig implements FileClientConfig { | ||
| 91 | * 5. 七牛云:不需要填写,会自动识别 | 96 | * 5. 七牛云:不需要填写,会自动识别 |
| 92 | * 6. 华为云:不需要填写,会自动识别 | 97 | * 6. 华为云:不需要填写,会自动识别 |
| 93 | * 7. 火山云:不需要填写,会自动识别 | 98 | * 7. 火山云:不需要填写,会自动识别 |
| 99 | + * 8. RustFS:需与服务端的 RUSTFS_REGION 一致,默认 us-east-1;不填写时,也使用 us-east-1 | ||
| 94 | */ | 100 | */ |
| 95 | private String region; | 101 | private String region; |
| 96 | 102 |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/package-info.java
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | * 2. ftp:FTP 服务器 | 5 | * 2. ftp:FTP 服务器 |
| 6 | * 3. sftp:SFTP 服务器 | 6 | * 3. sftp:SFTP 服务器 |
| 7 | * 4. db:数据库 | 7 | * 4. db:数据库 |
| 8 | - * 5. s3:支持 S3 协议的云存储服务,例如说 MinIO、阿里云、华为云、腾讯云、七牛云等等 | 8 | + * 5. s3:支持 S3 协议的云存储服务,例如说 MinIO、RustFS、阿里云、华为云、腾讯云、七牛云等等 |
| 9 | * | 9 | * |
| 10 | * @author 芋道源码 | 10 | * @author 芋道源码 |
| 11 | */ | 11 | */ |