jcberquist / aws-cfml

Lucee/ColdFusion library for interacting with AWS API's
MIT License
72 stars 53 forks source link

how to get the size of a bucket? #59

Closed artknight closed 2 years ago

artknight commented 2 years ago

Hi, sorry to be posting this question here.. :)

I am using the s3 hookup of your library and I need to be able to get the size in MB or GB of a specific bucket. How would I do that?

Thanks in advance! Art

ddspringle commented 2 years ago

Hey Art,

Looking at the code my assumption would be that you would need to use either the listBucket or listBucketV2 function in the S3 service cfc to get a list of all the objects in the bucket. From that data you should be able to arrayReduce() the file sizes to get the total and from that you can divide as needed to get MB/GB.

From what I recall I don’t believe there is a method in the AWS SDK or API to just get the total size of a bucket, but I also haven’t looked at either in awhile so will defer on that to someone who may know otherwise. In either case that method, if it exists, is not currently implemented in this library.

HTH

— Denny

artknight commented 2 years ago

@ddspringle Thank you!