AWS S3: Get the Latest Changed Java Timeline

I wrote java code to get the list of files in the AWS S3 buks folder as a list of strings. Is there any direct function that I could use to get the last modified timestamp of the file we see in the s3 buckets.

+5
source share
3 answers
Examples

s3 (LISTING CONTENT OF BUCKET), found at:

http://docs.ceph.com/docs/master/radosgw/s3/java/

+1
source

Alternatively you can use minio-java . Its Open Source and compatible with AWS S3 API.

Using the ListBuckets API, you can easily implement it.

  try {
   // List buckets that have read access.
   List bucketList = minioClient.listBuckets ();
   for (Bucket bucket: bucketList) {
       System.out.println (bucket.creationDate () + "," + bucket.name ());
   }
 } catch (MinioException e) {
   System.out.println ("Error occured:" + e);
 }

Hope this helps.

Disclaimer: I work for Minio

+1
source

You can get lastModified as java.util.Date through the S3ObjectSummary object.

 // ... ListObjectsV2Request listObjectsV2Request = new ListObjectsV2Request() .withBucketName("my-bucket") .withMaxKeys(1000); ListObjectsV2Result result = s3client.listObjectsV2(listObjectsV2Request); for (S3ObjectSummary objectSummary : result.getObjectSummaries()) { // objectSummary.getLastModified() as java.util.Date } 
+1
source

Source: https://habr.com/ru/post/1245546/


All Articles