I am trying to calculate the total size of an S3 bucket using my Java Spring MVC
web application. I am using jets3t
for my S3 access.
I have the following method to calculate the total file size of an S3 bucket.
public Long getBucketSize(String accessKeyId, String secretAccessKey, String bucketname) throws IOException, S3ServiceException
{
AWSCredentials awsCredentials =
new AWSCredentials(accessKeyId, secretAccessKey);
S3Service s3Service = new RestS3Service(awsCredentials);
S3Object[] objects = s3Service.listObjects(bucketname);
if(objects != null)
{
for (S3Object s3Object : objects)
{
}
}
return null;
}
But I cannot find any way to calculate the total file size of a bucket. Is there any way to find that?