w41ter commented on code in PR #25847:
URL: https://github.com/apache/doris/pull/25847#discussion_r1371009324


##########
fe/fe-core/src/main/java/org/apache/doris/common/util/S3URI.java:
##########
@@ -111,16 +111,12 @@ private S3URI(String location, boolean 
forceVirtualHosted) throws UserException
             //          endpoint:           http://cos.ap-beijing.myqcloud.com
             //          bucket/path:        my_bucket/file.txt
             // `virtualBucket` will be "my_bucket"
-            // `bucket` will be `file.txt`
+            // `bucket` will be `/`
+            // `key` will be `file.txt`
             // So that when assembling the real endpoint will be: 
http://my_bucket.cos.ap-beijing.myqcloud.com/file.txt
             this.virtualBucket = authoritySplit[0];
-            String[] paths = path.split("/", 2);
-            this.bucket = paths[0];
-            if (paths.length > 1) {
-                key = paths[1];
-            } else {
-                key = "";
-            }
+            this.bucket = "/";

Review Comment:
   Separating the path into a bucket and key in visual hosted style is not 
correct in the former implementation. Some APIs such as get/putObject work by 
chance, but others don't. 
   
   For example, to list keys by prefix: `A/B`, the SDK `listObjects` API will 
generate HTTP request:
   
   ```
   GET /A?list-type=2&prefix=B/ HTTP/1.1
   ```
   
   Some s3 compatible services will not recognize this formal and report `The 
specified key does not exist`. The correct HTTP should likes this:
   
   ```
   GET /?list-type=2&prefix=A/B/ HTTP/1.1
   ```
   
   Since the SDK constructs HTTP path like 
`/<bucket>?list-type=2&prefix=<key>`, the bucket should be set to a non-empty 
value '/'.
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to