I store two million files in an Amazon S3 bucket. Below is the root directory (l1), a list of directories under l1, and then each directory contains files. So my bucket will look something like this:
l1/a1/file1-1.jpg l1/a1/file1-2.jpg l1/a1/... another 500 files l1/a2/file2-1.jpg l1/a2/file2-2.jpg l1/a2/... another 500 files .... l1/a5000/file5000-1.jpg
I would like to list the second level entries as quickly as possible, so I would like to get a1, a2, a5000. I do not want to list all the keys, it will take a lot more time.
I am open to the direct use of AWS api, however I have played with the right_aws gem in ruby ββso far http://rdoc.info/projects/rightscale/right_aws p>
There are at least two APIs in this stone, I tried to use bucket.keys () in the S3 module and incrementally_list_bucket () in the S3Interface module. For example, I can set the prefix and separator to display all l1 / a1 / *, but I cannot figure out how to list only the first level in l1. There is an entry in the hash: common_prefixes, returned by incrementally_list_bucket (), but it is not populated in my test sample.
Is this operation possible using the S3 API?
Thanks!
source share