Browse Source

fix(oss):修正云服务商访问样式判断逻辑

- 针对阿里云OSS、腾讯云COS、七牛云等云服务商,明确使用虚拟主机样式访问
- 避免这些云服务商错误地启用路径样式访问- 提高与主流云存储服务的兼容性
zhou 1 month ago
parent
commit
2176feee30

+ 3 - 1
ruoyi-common/ruoyi-common-oss/src/main/java/org/dromara/common/oss/core/OssClient.java

@@ -85,7 +85,9 @@ public class OssClient {
                 AwsBasicCredentials.create(properties.getAccessKey(), properties.getSecretKey()));
 
             // MinIO 使用 HTTPS 限制使用域名访问,站点填域名。需要启用路径样式访问
-            boolean isStyle = !StringUtils.containsAny(properties.getEndpoint(), OssConstant.CLOUD_SERVICE);
+            // 阿里云OSS、腾讯云COS、七牛云等云服务商使用虚拟主机样式访问
+            boolean isStyle = !StringUtils.containsAny(properties.getEndpoint(), OssConstant.CLOUD_SERVICE) 
+                && !StringUtils.containsAny(properties.getEndpoint(), new String[]{"aliyuncs.com", "myqcloud.com", "qiniucs.com"});
 
             // 创建AWS基于 Netty 的 S3 客户端
             this.client = S3AsyncClient.builder()