Commit 4386c7018cab5ad42878b21b6898f05fc92f837b
1 parent
d9b913a7
【功能优化】全局:文件存储 S3 兼容腾讯云、火山云的 VirtualStyle 模式
Showing
2 changed files
with
13 additions
and
0 deletions
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<S3FileClientConfig> { |
| 37 | 37 | .region(buildRegion()) // Region |
| 38 | 38 | .credentials(config.getAccessKey(), config.getAccessSecret()) // 认证密钥 |
| 39 | 39 | .build(); |
| 40 | + enableVirtualStyleEndpoint(); | |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | 43 | /** |
| ... | ... | @@ -86,6 +87,17 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { |
| 86 | 87 | return null; |
| 87 | 88 | } |
| 88 | 89 | |
| 90 | + /** | |
| 91 | + * 开启 VirtualStyle 模式 | |
| 92 | + */ | |
| 93 | + private void enableVirtualStyleEndpoint() { | |
| 94 | + if (StrUtil.containsAll(config.getEndpoint(), | |
| 95 | + S3FileClientConfig.ENDPOINT_TENCENT, // 腾讯云 https://cloud.tencent.com/document/product/436/41284 | |
| 96 | + S3FileClientConfig.ENDPOINT_VOLCES)) { // 火山云 https://www.volcengine.com/docs/6349/1288493 | |
| 97 | + client.enableVirtualStyleEndpoint(); | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 89 | 101 | @Override |
| 90 | 102 | public String upload(byte[] content, String path, String type) throws Exception { |
| 91 | 103 | // 执行上传 | ... | ... |
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 { |
| 20 | 20 | public static final String ENDPOINT_QINIU = "qiniucs.com"; |
| 21 | 21 | public static final String ENDPOINT_ALIYUN = "aliyuncs.com"; |
| 22 | 22 | public static final String ENDPOINT_TENCENT = "myqcloud.com"; |
| 23 | + public static final String ENDPOINT_VOLCES = "volces.com"; // 火山云(字节) | |
| 23 | 24 | |
| 24 | 25 | /** |
| 25 | 26 | * 节点地址 | ... | ... |