The Java call below shows how paginated listing can be used to return the keys in an Amazon Web Services "directory".
Amazon Web Services (AWS) S3 storage is a massively parallel network resource that can be used to store large amounts of data with high reliability and relatively low cost. This makes S3 a key component for many applications ranging from web log analysis to company data lakes.
AWS S3 storage is structured around "buckets" which are globally unique logical containers for S3 content. The files that are stored in S3 are referenced via keys, which are logically structured like directories. For example, the content for topstonesoftware.com is stored in an S3 bucket named topstonesoftware.com. The article Spring and DynamoDB has the S3 key
S3 buckets often store large numbers of keys. Even when the keys are distributed within "sub-directories", the contents of a sub-directory often cannot be listed in a single operation because the number of keys returned would not fit in memory.
The AWS Java SDK supports paginated directory listing. There are two ways (in theory) to list directories. A "continuation" token can be returned by the ListObjectsV2Result (via the getContinuationToken() function) or an S3 key can be passed to the ListObjectsV2Result startAfter() function. I have never been able to get the continuation token to work. The code below uses the last S3 key from the previous list operation as the start for the next key list.