desruisseaux commented on code in PR #40:
URL: https://github.com/apache/sis/pull/40#discussion_r2792637454


##########
endorsed/src/org.apache.sis.cloud.aws/main/org/apache/sis/cloud/aws/s3/FileService.java:
##########
@@ -308,7 +446,39 @@ public Path getPath(final URI uri) {
             if (host == null) host = uri.toString();
             throw new 
IllegalArgumentException(Resources.format(Resources.Keys.InvalidBucketName_1, 
host));
         }
-        final String path = uri.getPath();
+
+        final ClientFileSystem fs;
+        if (accessKey == null && port == -1) {
+            fs = getDefaultFileSystem();
+        } else if (accessKey == null && port > -1) {
+            fs = getDefaultFileSystem(host, port);
+        } else {
+            // TODO: we may need a way to get password here.
+            ClientFileSystemKey fsKey;
+
+            if (port == -1) {
+                fsKey = new ClientFileSystemKey(accessKey, DEFAULT_HOST_KEY, 
DEFAULT_PORT_KEY);
+            } else {
+                fsKey = new ClientFileSystemKey(accessKey, host, port);
+            }
+            fs = fileSystems.computeIfAbsent(fsKey, (key) ->
+                    new ClientFileSystem(FileService.this, null, 
key.getHost(), key.getPort(), key.isHttps(), key.getAccessKey(), null, null));
+        }
+
+        String path = uri.getPath();
+
+        if (fs.host != null) {
+            if (!(fs.host.equalsIgnoreCase(DEFAULT_HOST_KEY))) {
+                path = path.substring(1);

Review Comment:
   Why skipping the first character? Is it for skipping a leading `/`? If so, 
are we certain that this leading character will always be present?



-- 
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]

Reply via email to