1

I am trying to get list of keys with some prefix in amazon s3 bucket. I followed the steps shown here But still i am get keys available in that bucket with that prefix. Below is the code i tried.

conn = boto.connect_s3(anon=True)
bucket = conn.get_bucket('aws-publicdatasets')
for each_rs in self.bucket.list(prefix="/project_prefix/prefx_key2/prefix_key3/"):
    print each_rs.name

But the below code is working fine to retrieve all the keys in aws puvlic data sets

conn = boto.connect_s3(anon=True)
bucket = conn.get_bucket('aws-publicdatasets')
for each_rs in self.bucket.list():
    print each_rs.name

I tried with get_all_keys(prefix="/project_prefix/prefx_key2/prefix_key3/") but still no luck. Is there any other way to get list of keys having given prefix?

user2695817
  • 121
  • 1
  • 7
  • Had that issue as well and didn't solve it yet. It wasn't really necessary for me back then, so I didn't pursuit it any longer, but I'd be interested in an answer as well! – Alfe Jan 23 '14 at 12:07

1 Answers1

0

you get the keys only for a defined prefix. Try this:

import boto
conn = boto.connect_s3(anon=True)
bucket = conn.get_bucket('aws-publicdatasets')
list = bucket.list("common-crawl/crawl-001/2008/08/22/28")
for key in list:
    print key.name
admirableadmin
  • 2,669
  • 1
  • 24
  • 41