From 4386c7018cab5ad42878b21b6898f05fc92f837b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 27 Jul 2024 10:23:24 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=85=A8=E5=B1=80=EF=BC=9A=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8=20S3=20=E5=85=BC=E5=AE=B9=E8=85=BE=E8=AE=AF=E4=BA=91?= =?UTF-8?q?=E3=80=81=E7=81=AB=E5=B1=B1=E4=BA=91=E7=9A=84=20VirtualStyle=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/file/core/client/s3/S3FileClient.java | 12 ++++++++++++ .../file/core/client/s3/S3FileClientConfig.java | 1 + 2 files changed, 13 insertions(+) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java index 67995caa28..43ff2733b1 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClient.java @@ -37,6 +37,7 @@ public class S3FileClient extends AbstractFileClient { .region(buildRegion()) // Region .credentials(config.getAccessKey(), config.getAccessSecret()) // 认证密钥 .build(); + enableVirtualStyleEndpoint(); } /** @@ -86,6 +87,17 @@ public class S3FileClient extends AbstractFileClient { return null; } + /** + * 开启 VirtualStyle 模式 + */ + private void enableVirtualStyleEndpoint() { + if (StrUtil.containsAll(config.getEndpoint(), + S3FileClientConfig.ENDPOINT_TENCENT, // 腾讯云 https://cloud.tencent.com/document/product/436/41284 + S3FileClientConfig.ENDPOINT_VOLCES)) { // 火山云 https://www.volcengine.com/docs/6349/1288493 + client.enableVirtualStyleEndpoint(); + } + } + @Override public String upload(byte[] content, String path, String type) throws Exception { // 执行上传 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java index 872bc0d185..e8f8bacec5 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/s3/S3FileClientConfig.java @@ -20,6 +20,7 @@ public class S3FileClientConfig implements FileClientConfig { public static final String ENDPOINT_QINIU = "qiniucs.com"; public static final String ENDPOINT_ALIYUN = "aliyuncs.com"; public static final String ENDPOINT_TENCENT = "myqcloud.com"; + public static final String ENDPOINT_VOLCES = "volces.com"; // 火山云(字节) /** * 节点地址