1
votes

I have a bucket named "mybuckettest" in my AWS account. Inside this bucket I have multiple folders like "Folder1", "Folder2", "Folder3". Inside each of these folders, I have sub folders as well. It can be simulated as shown below:

mybuckettest
    Folder1
        subfolder1
             content1
             content2
             content3
             content4
        subfolder2
             content1
    Folder2
        subfolder1
    Folder3
        subfolder1
             content1
             content2

I am trying to figure out the size of each folders "Folder1", "Folder2", "Folder3" separately. Is there any specific way to do this using API? I mean I am trying to build an application through which I want to do this. Does anyone has an idea on this? My application language is Python-Django.

2

2 Answers

1
votes
Folder1
    subfolder1
         content1

is just on key named Folder1/subfolder1/content1.
If you know all keys, then just add their all Content-Length by GET Object; else you can get all keys's info in same prefix(eg: Folder1) by GET Bucket (List Objects) Version 2 with prefix in Request, then add their all Size.

0
votes

An alternative is to use Amazon S3 Storage Inventory, which can provide a daily CSV file of the contents of your Amazon S3 buckets.

You could then parse this file with a simple Python script rather than calling making API List calls.