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