Vikas Gupta
Vikas Gupta

Reputation: 1530

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?

Upvotes: 0

Views: 801

Answers (1)

parsifal
parsifal

Reputation: 1663

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<?>>.

Upvotes: 2

Related Questions