简体   繁体   中英

Iterate folders in an Amazon S3 bucket

I have below structure in my bucket

testing -- bucket name
test/order/text1.txt
test/order/text2.txt
test/order2/abc.txt
test/order3/abc.txt

and I want to iterate it like this

testing

     test

      -order

            text1.txt
            text2.txt

     -order2
            abc.txt

     -order3
            abc.txt

When I use listObjectSummary , it gives me file details not folder details, so can anyone help me how I can get folder details in a bucket?

Amazon doesn't have folders per se , it's simply a convenient way to format keys (note that I didn't say "filenames").

This means that you'll have to break apart the keys yourself, to simulate a folder structure. Probably the easiest way to do this in Java is with a hierarchical tree of maps: TreeMap<String,Map<?>> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM