【发布时间】:2016-10-12 18:48:24
【问题描述】:
我有两个 s3 存储桶,取“srcs3bck”和“dsts3bck”,我在 srcs3bck 中有一个文本文件。我尝试了StackOverFlow question 中建议的答案,将源复制到目标。但是当我这样做时,我收到 404 响应错误,说明我的源存储桶不可用。
但我试图获得桶并获得所有 kes。它正在显示密钥。
>>> import boto
>>> conn=boto.connect(<credentials>)
>>> src = conn.get_bucket("srcs3bck")
>>> src.get_all_keys()
printing my key list properly.
>>> dst = conn.get_bucket("dsts3bck")
>>>
>>> src.get_all_keys()
[<Key: srcs3bck,Test2.txt>]
>>>
>>> src.list()
<boto.s3.bucketlistresultset.BucketListResultSet object at 0x03768310>
>>> x=src.list()
>>> for i in x: print i
<Key: srcs3bck,Test2.txt>
>>> for i in x: print i.key
Test2.txt
>>> for i in x: dst.copy_key(i.key,src,i.key)
.......
ignoring other lines
....
S3ResponseError: S3ResponseError: 404 Not Found
<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName><Bucket: srcs3bck></BucketName><RequestId>358C4C2420BB91E9</RequestId><HostId>ws6wagGIZqquStqisfGuYHeMMscmmR2Iu8LL4jCv9KpLBzxieiryI/mRwxwz4aQ=</HostId></Error>
>>>
我还需要改变什么。我不确定我在做什么错误。谁能帮我解决这个问题。提前致谢
【问题讨论】:
标签: python amazon-web-services amazon-s3 boto3