Skip to content

Conversation

@pashagolub
Copy link

This commit adds support for the --start-after parameter to enable pagination when listing S3 objects, allowing users to resume listing from a specific key.

Changes:

  • storage/url: Add StartAfter field to URL struct and WithStartAfter() option function for constructing URLs with pagination support
  • storage/s3: Update listObjectsV2() to pass StartAfter parameter to AWS S3 ListObjectsV2 API call
  • command/ls: Add --start-after CLI flag with validation and help text
  • README.md: Add "Listing objects with pagination" section with usage examples demonstrating basic and advanced use cases
  • e2e/ls_test: Add comprehensive integration tests for --start-after functionality including:
    • Basic pagination with bucket root
    • Pagination with prefix filtering
    • Pagination with wildcard patterns
    • Pagination with wildcard and extension filtering

Tests skip on gofakes3 mock backend (which doesn't properly implement the StartAfter parameter) and run when S5CMD_TEST_ENDPOINT_URL is configured to point to a real S3-compatible endpoint.

Verified against:

  • AWS S3 public bucket (globalnightlight)
  • MinIO server (localhost:9000)

Example usage:
s5cmd ls --start-after "logs/2024/file2.txt" s3://bucket/logs/2024/ s5cmd ls --start-after "b.txt" s3://bucket/*.txt

Fixes pagination for large buckets and enables efficient incremental listing workflows.

This commit adds support for the `--start-after` parameter to enable
pagination when listing S3 objects, allowing users to resume listing
from a specific key.

Changes:
- storage/url: Add StartAfter field to URL struct and WithStartAfter()
  option function for constructing URLs with pagination support
- storage/s3: Update listObjectsV2() to pass StartAfter parameter to
  AWS S3 ListObjectsV2 API call
- command/ls: Add --start-after CLI flag with validation and help text
- README.md: Add "Listing objects with pagination" section with usage
  examples demonstrating basic and advanced use cases
- e2e/ls_test: Add comprehensive integration tests for --start-after
  functionality including:
  * Basic pagination with bucket root
  * Pagination with prefix filtering
  * Pagination with wildcard patterns
  * Pagination with wildcard and extension filtering

Tests skip on gofakes3 mock backend (which doesn't properly implement
the StartAfter parameter) and run when S5CMD_TEST_ENDPOINT_URL
is configured to point to a real S3-compatible endpoint.

Verified against:
- AWS S3 public bucket (globalnightlight)
- MinIO server (localhost:9000)

Example usage:
  s5cmd ls --start-after "logs/2024/file2.txt" s3://bucket/logs/2024/
  s5cmd ls --start-after "b.txt" s3://bucket/*.txt

Fixes pagination for large buckets and enables efficient incremental
listing workflows.
@pashagolub pashagolub requested a review from a team as a code owner November 10, 2025 10:36
@pashagolub pashagolub requested review from igungor and seruman and removed request for a team November 10, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant