I am using boto and python and amazon s3.
If I use
[key.name for key in list(self.bucket.list())]
then I get all the keys of all the files.
mybucket/files/pdf/abc.pdf mybucket/files/pdf/abc2.pdf mybucket/files/pdf/abc3.pdf mybucket/files/pdf/abc4.pdf mybucket/files/pdf/new/ mybucket/files/pdf/new/abc.pdf mybucket/files/pdf/2011/
what is the best way to
1. either get all folders from s3 2. or from that list just remove the file from the last and get the unique keys of folders
I am thinking of doing like this
set([re.sub("/[^/]*$","/",path) for path in mylist]
building on sethwm's answer:
To get the top level directories:
list(bucket.list("", "/"))
To get the subdirectories of files
:
list(bucket.list("files/", "/")
and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With