Untitled
unknown
plain_text
a year ago
776 B
5
Indexable
private static Optional<S3ObjectSummary> findLatestCSVFile(AmazonS3 s3Client) {
ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(BUCKET_NAME).withPrefix(PREFIX);
ListObjectsV2Result result;
List<S3ObjectSummary> csvFiles;
do {
result = s3Client.listObjectsV2(req);
csvFiles = result.getObjectSummaries().stream()
.filter(obj -> obj.getKey().endsWith(".csv"))
.collect(Collectors.toList());
String token = result.getNextContinuationToken();
req.setContinuationToken(token);
} while (result.isTruncated());
return csvFiles.stream()
.max(Comparator.comparing(S3ObjectSummary::getLastModified));
}Editor is loading...
Leave a Comment