I used it to get the video size in HLS format!
client = AWS::S3::new
size = 0
options = { bucket: [Bucket name], prefix: [Prefix] }
loop do
object_list = client.list_objects_v2(options)
object_list.contents.each do |object|
size += object.size
end
options[:continuation_token] = object_list.next_continuation_token
break unless object_list.next_continuation_token
end
gigabyte = (size / (2 ** 30).to_f).round(2)
CLI makes it even easier Get the total number of files and file size on S3 using AWS CLI
$ aws s3 ls s3://[Bucket name]/[Folder name]/ --recursive --human --sum
I regret that I should have written it in Lambda after implementation.
Recommended Posts