Commit 2b87f6a59d6aab3dfe7e766cce2e46e938816765
Committed by
Gitee
!347 fix: 腾讯 COS 异常,Region 必传
Merge pull request !347 from 与或非/issues/I5N76T
Showing
2 changed files
with
8 additions
and
1 deletions
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClient.java
| @@ -9,10 +9,11 @@ import io.minio.*; | @@ -9,10 +9,11 @@ import io.minio.*; | ||
| 9 | import java.io.ByteArrayInputStream; | 9 | import java.io.ByteArrayInputStream; |
| 10 | 10 | ||
| 11 | import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN; | 11 | import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_ALIYUN; |
| 12 | +import static cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig.ENDPOINT_TENCENT; | ||
| 12 | 13 | ||
| 13 | /** | 14 | /** |
| 14 | * 基于 S3 协议的文件客户端,实现 MinIO、阿里云、腾讯云、七牛云、华为云等云服务 | 15 | * 基于 S3 协议的文件客户端,实现 MinIO、阿里云、腾讯云、七牛云、华为云等云服务 |
| 15 | - * | 16 | + * <p> |
| 16 | * S3 协议的客户端,采用亚马逊提供的 software.amazon.awssdk.s3 库 | 17 | * S3 协议的客户端,采用亚马逊提供的 software.amazon.awssdk.s3 库 |
| 17 | * | 18 | * |
| 18 | * @author 芋道源码 | 19 | * @author 芋道源码 |
| @@ -78,6 +79,11 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { | @@ -78,6 +79,11 @@ public class S3FileClient extends AbstractFileClient<S3FileClientConfig> { | ||
| 78 | .replaceAll("-internal", "")// 去除内网 Endpoint 的后缀 | 79 | .replaceAll("-internal", "")// 去除内网 Endpoint 的后缀 |
| 79 | .replaceAll("https://", ""); | 80 | .replaceAll("https://", ""); |
| 80 | } | 81 | } |
| 82 | + // 腾讯云必须有 region,否则会报错 | ||
| 83 | + if (config.getEndpoint().contains(ENDPOINT_TENCENT)) { | ||
| 84 | + return StrUtil.subAfter(config.getEndpoint(), ".cos.", false) | ||
| 85 | + .replaceAll("." + ENDPOINT_TENCENT, ""); // 去除 Endpoint | ||
| 86 | + } | ||
| 81 | return null; | 87 | return null; |
| 82 | } | 88 | } |
| 83 | 89 |
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientConfig.java
| @@ -19,6 +19,7 @@ public class S3FileClientConfig implements FileClientConfig { | @@ -19,6 +19,7 @@ public class S3FileClientConfig implements FileClientConfig { | ||
| 19 | 19 | ||
| 20 | public static final String ENDPOINT_QINIU = "qiniucs.com"; | 20 | public static final String ENDPOINT_QINIU = "qiniucs.com"; |
| 21 | public static final String ENDPOINT_ALIYUN = "aliyuncs.com"; | 21 | public static final String ENDPOINT_ALIYUN = "aliyuncs.com"; |
| 22 | + public static final String ENDPOINT_TENCENT = "myqcloud.com"; | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * 节点地址 | 25 | * 节点地址 |