clintropolis commented on a change in pull request #8903: S3 input source
URL: https://github.com/apache/incubator-druid/pull/8903#discussion_r350494804
 
 

 ##########
 File path: 
extensions-core/s3-extensions/src/main/java/org/apache/druid/storage/s3/S3Utils.java
 ##########
 @@ -168,6 +244,26 @@ public S3ObjectSummary next()
     };
   }
 
+
+  /**
+   * Create an {@link URI} from the given {@link S3ObjectSummary}. The result 
URI is composed as below.
+   *
+   * <pre>
+   * {@code s3://{BUCKET_NAME}/{OBJECT_KEY}}
+   * </pre>
+   */
+  public static URI summaryToUri(S3ObjectSummary object)
+  {
+    final String originalAuthority = object.getBucketName();
+    final String originalPath = object.getKey();
+    final String authority = originalAuthority.endsWith("/") ?
+                             originalAuthority.substring(0, 
originalAuthority.length() - 1) :
+                             originalAuthority;
+    final String path = originalPath.startsWith("/") ? 
originalPath.substring(1) : originalPath;
+
+    return URI.create(StringUtils.format("s3://%s/%s", authority, path));
 
 Review comment:
   FYI this method in `S3Utils` was only called by `StaticS3FirehoseFactory`, 
not the new stuff, so I wasn't worrying about it too much because we presumably 
will remove it in a future release. That said, I went ahead and did the thing 
to fix it

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to