@Test void listBatchObjects() { int s3BatchSize = 1000; int extraKeys = 100; List<String> keys = new ArrayList<>(); for (int i = 1; i <= s3BatchSize + extraKeys; i++) { keys.add(keyRoot + "/file" + i); } keys.parallelStream() .forEach(key -> amazonS3.putObject(bucket, key, content)); List<S3ObjectSummary> result = s3Client.listObjects(bucket, keyRoot); assertThat(result.size()).isEqualTo(s3BatchSize + extraKeys); }
List<S3ObjectSummary> listObjects(String bucket, String key) { List<S3ObjectSummary> objectSummaries = new ArrayList<>(); ListObjectsV2Result listObjectsV2Result; String continuationToken = null; do { ListObjectsV2Request request = new ListObjectsV2Request() .withBucketName(bucket) .withPrefix(key) .withEncodingType("url") .withContinuationToken(continuationToken); listObjectsV2Result = amazonS3.listObjectsV2(request); objectSummaries.addAll(listObjectsV2Result.getObjectSummaries()); continuationToken = listObjectsV2Result.getNextContinuationToken(); } while (listObjectsV2Result.isTruncated()); return objectSummaries; }
S3Client { List<S3ObjectSummary> listObjects(String bucket, String key) { List<S3ObjectSummary> objectSummaries = new ArrayList<>(); ListObjectsV2Result listObjectsV2Result; String continuationToken = null; do { ListObjectsV2Request request = new ListObjectsV2Request() .withBucketName(bucket) .withPrefix(key) .withEncodingType("url") .withContinuationToken(continuationToken); listObjectsV2Result = amazonS3.listObjectsV2(request); objectSummaries.addAll(listObjectsV2Result.getObjectSummaries()); continuationToken = listObjectsV2Result.getNextContinuationToken(); } while (listObjectsV2Result.isTruncated()); return objectSummaries; } }
S3Client { List<S3ObjectSummary> listObjects(String bucket, String key) { List<S3ObjectSummary> objectSummaries = new ArrayList<>(); ListObjectsV2Result listObjectsV2Result; String continuationToken = null; do { ListObjectsV2Request request = new ListObjectsV2Request() .withBucketName(bucket) .withPrefix(key) .withEncodingType("url") .withContinuationToken(continuationToken); listObjectsV2Result = amazonS3.listObjectsV2(request); objectSummaries.addAll(listObjectsV2Result.getObjectSummaries()); continuationToken = listObjectsV2Result.getNextContinuationToken(); } while (listObjectsV2Result.isTruncated()); return objectSummaries; } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled); }
S3Client { List<S3ObjectSummary> listObjects(String bucket, String key) { List<S3ObjectSummary> objectSummaries = new ArrayList<>(); ListObjectsV2Result listObjectsV2Result; String continuationToken = null; do { ListObjectsV2Request request = new ListObjectsV2Request() .withBucketName(bucket) .withPrefix(key) .withEncodingType("url") .withContinuationToken(continuationToken); listObjectsV2Result = amazonS3.listObjectsV2(request); objectSummaries.addAll(listObjectsV2Result.getObjectSummaries()); continuationToken = listObjectsV2Result.getNextContinuationToken(); } while (listObjectsV2Result.isTruncated()); return objectSummaries; } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled);  }
S3Client { List<S3ObjectSummary> listObjects(String bucket, String key) { List<S3ObjectSummary> objectSummaries = new ArrayList<>(); ListObjectsV2Result listObjectsV2Result; String continuationToken = null; do { ListObjectsV2Request request = new ListObjectsV2Request() .withBucketName(bucket) .withPrefix(key) .withEncodingType("url") .withContinuationToken(continuationToken); listObjectsV2Result = amazonS3.listObjectsV2(request); objectSummaries.addAll(listObjectsV2Result.getObjectSummaries()); continuationToken = listObjectsV2Result.getNextContinuationToken(); } while (listObjectsV2Result.isTruncated()); return objectSummaries; } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled);   }