-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Support ListObjectsV2 in S3HttpHandler
#126189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,8 +207,9 @@ public void handle(final HttpExchange exchange) throws IOException { | |
| exchange.sendResponseHeaders(RestStatus.OK.getStatus(), -1); | ||
|
|
||
| } else if (request.isListObjectsRequest()) { | ||
| if (request.queryParameters().containsKey("list-type")) { | ||
| throw new AssertionError("Test must be adapted for GET Bucket (List Objects) Version 2"); | ||
| final var listType = request.queryParameters().getOrDefault("list-type", List.of("1")).get(0); | ||
|
||
| if (request.queryParameters().containsKey("list-type") && listType.equals("2") == false) { | ||
| throw new AssertionError("Unsupported list-type, must be absent or `2` but got " + listType); | ||
| } | ||
|
|
||
| final StringBuilder list = new StringBuilder(); | ||
|
|
@@ -223,6 +224,9 @@ public void handle(final HttpExchange exchange) throws IOException { | |
| if (delimiter != null) { | ||
| list.append("<Delimiter>").append(delimiter).append("</Delimiter>"); | ||
| } | ||
| // Would be good to test pagination here (the only real difference between ListObjects and ListObjectsV2) but for now | ||
| // we return all the results at once. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this explanation be partly phrased as a TODO?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hold no hope that we'll actually do it so I'm going to just leave it as a comment. |
||
| list.append("<IsTruncated>false</IsTruncated>"); | ||
| for (Map.Entry<String, BytesReference> blob : blobs.entrySet()) { | ||
| if (prefix != null && blob.getKey().startsWith("/" + bucket + "/" + prefix) == false) { | ||
| continue; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify with a comment that V2 requests newly have this extra version (?) field, so we're adding the check in case the version unexpectedly changes in future? That's my understanding, anyway, from looking around on the internet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can replace it something like
Seems more explicit with the intention and also ensures the parameter has a single value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All fair points. Previously I was doing something with the
listTypevalue so it was useful to distinguish "1" from "2", but we don't need this right now so we can just drop this check entirely -> 5974795