mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
Fix ListObjects v1 marker pagination (#939)
When listing with a prefix and a marker, the v1 ListObjects API was ignoring the marker entirely, causing the same page to be returned on every paginated call. Pass the marker as startAfter to listObjectsWithPrefixes for v1 requests so pagination advances correctly. Also emit <Marker> and <NextMarker> in the v1 XML response.
This commit is contained in:
1 parent
6819bce493
commit
ce1f565003
1 file changed
+10
-1
@@ -280,6 +280,7 @@ public class S3Controller {
|
||||
@QueryParam("start-after") String startAfter,
|
||||
@QueryParam("encoding-type") String encodingType,
|
||||
@QueryParam("key-marker") String keyMarker,
|
||||
@QueryParam("marker") String marker,
|
||||
@Context UriInfo uriInfo) {
|
||||
validateRawUri();
|
||||
try {
|
||||
@@ -355,8 +356,11 @@ public class S3Controller {
|
||||
}
|
||||
|
||||
int max = (maxKeys != null && maxKeys > 0) ? maxKeys : 1000;
|
||||
boolean v1 = !"2".equals(listType);
|
||||
String effectiveStartAfter = v1 && marker != null ? marker : startAfter;
|
||||
String effectiveContinuationToken = v1 ? null : continuationToken;
|
||||
S3Service.ListObjectsResult result = s3Service.listObjectsWithPrefixes(
|
||||
bucket, prefix, delimiter, max, continuationToken, startAfter);
|
||||
bucket, prefix, delimiter, max, effectiveContinuationToken, effectiveStartAfter);
|
||||
List<S3Object> objects = result.objects();
|
||||
List<String> commonPrefixes = result.commonPrefixes();
|
||||
boolean v2 = "2".equals(listType);
|
||||
@@ -399,6 +403,11 @@ public class S3Controller {
|
||||
if (startAfter != null) {
|
||||
xml.elem("StartAfter", startAfter);
|
||||
}
|
||||
} else {
|
||||
xml.elem("Marker", marker != null ? marker : "");
|
||||
if (result.isTruncated() && result.nextContinuationToken() != null) {
|
||||
xml.elem("NextMarker", result.nextContinuationToken());
|
||||
}
|
||||
}
|
||||
xml.end("ListBucketResult");
|
||||
return Response.ok(xml.build()).build();
|
||||
|
||||
Reference in new issue
Block a user