Skip to content

Commit 5fbf4b1

Browse files
authored
branch-3.1: [fix](oss)Support Aliyun OSS S3-Compatible Public Endpoint Format s3.oss-cn-xxx.aliyuncs.com apache#51894 (apache#53368)
picked from apache#51894
1 parent b7c20d3 commit 5fbf4b1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/datasource/property/storage/OSSProperties.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,14 @@ public class OSSProperties extends AbstractS3CompatibleProperties {
6464
* - <a href="http://oss-cn-shenzhen-internal.aliyuncs.com">...</a> => region = cn-shenzhen
6565
* <p>
6666
* Group(1) captures the region name (e.g., cn-hangzhou).
67+
*<p>
68+
* Support S3 compatible endpoints:<a href="https://help.aliyun.com/zh/oss/developer-reference/
69+
* use-amazon-s3-sdks-to-access-oss">...</a>
70+
* - s3.cn-hangzhou.aliyuncs.com => region = cn-hangzhou
71+
* <p>
6772
*/
6873
private static final Pattern ENDPOINT_PATTERN = Pattern
69-
.compile("^(?:https?://)?oss-([a-z0-9-]+?)(?:-internal)?\\.aliyuncs\\.com$");
74+
.compile("^(?:https?://)?(?:s3\\.)?oss-([a-z0-9-]+?)(?:-internal)?\\.aliyuncs\\.com$");
7075

7176
protected OSSProperties(Map<String, String> origProps) {
7277
super(Type.OSS, origProps);

fe/fe-core/src/test/java/org/apache/doris/datasource/property/storage/OSSPropertiesTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public void testGetRegion() throws UserException {
107107
Assertions.assertEquals("oss-cn-hangzhou.aliyuncs.com", ossProperties.getEndpoint());
108108
origProps.put("oss.endpoint", "oss-cn-hangzhou-internal.aliyuncs.com");
109109
Assertions.assertEquals("cn-hangzhou", ((OSSProperties) StorageProperties.createPrimary(origProps)).getRegion());
110+
origProps.put("oss.endpoint", "s3.oss-cn-shanghai.aliyuncs.com");
111+
Assertions.assertEquals("cn-shanghai", ((OSSProperties) StorageProperties.createPrimary(origProps)).getRegion());
112+
origProps.put("oss.endpoint", "s3.oss-cn-hongkong-internal.aliyuncs.com");
113+
Assertions.assertEquals("cn-hongkong", ((OSSProperties) StorageProperties.createPrimary(origProps)).getRegion());
114+
origProps.put("oss.endpoint", "https://s3.oss-cn-hongkong-internal.aliyuncs.com");
115+
Assertions.assertEquals("cn-hongkong", ((OSSProperties) StorageProperties.createPrimary(origProps)).getRegion());
116+
origProps.put("oss.endpoint", "http://s3.oss-cn-hongkong.aliyuncs.com");
117+
Assertions.assertEquals("cn-hongkong", ((OSSProperties) StorageProperties.createPrimary(origProps)).getRegion());
110118
}
111119

112120
@Test

0 commit comments

Comments
 (0)