i want to read last modified or created date in a s3 file. i have seen the coding to list all files but i wanted to find a specific file's modified date.
i used this coding to retrive the s3 file
S3Object s3ProfileObject = s3Client.getObject(new GetObjectRequest(srcBucket, fullProfilePath));
InputStream profileData = s3ProfileObject.getObjectContent();
SONObject rawProfileObject = (JSONObject)jsonParser.parse( new InputStreamReader(profileData, "UTF-8"));
is it possible to read it using s3ProfileObject ?
You need to use
S3ObjectSummaryfor that. Here is the documentation for it. Below is the sample code (from here):From
S3ObjectSummary, you can make another request and getS3Object.If you want to include a specific file or files with specific prefix then you can use `` object with
withPrefixmethod along with the request, e.g.:ListObjectsV2Result result = s3client.listObjectsV2(listObjectsV2Request);
Here's the javadoc for
ListObjectsV2Request.