[英]Not able to extract keys in a amzon S3 bucket having some prefix using python boto
I am trying to get list of keys with some prefix in amazon s3 bucket. 我正在尝试在亚马逊s3存储桶中获取带有一些前缀的键列表。 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 但是下面的代码可以很好地检索AWS puvlic数据集中的所有键
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. 我尝试使用get_all_keys(prefix =“ / project_prefix / prefx_key2 / prefix_key3 /”),但还是没有运气。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.