我想将文件从存储桶移动到同一个存储桶/文件夹。
test
文件夹已存在。
srcBucket = "tmp"
dstBucket = "tmp"
import boto
c = boto.connect_s3()
src = c.get_bucket(srcBucket)
dst = c.get_bucket(dstBucket)
print dst
for k in src.list():
# copy stuff to your destination here
dst.copy_key(k.key, src.name, "/test/"+k.key)
我得到:
<Message>The specified key does not
exist.</Message><Key>/test/00hbgelokd2i5nglv6opbte003gorrnahv65uo81</Key>
最佳答案
S3 中的对象键不以 /
开头。
http://example-bucket.s3.amazonaws.com/foo/bar.txt
上的对象的键是 foo/bar.txt
,而不是/foo/bar.txt
。
因此,在您的示例中,"/test/"+k.key
应该是 "test/"+k.key
。
关于python - 将文件从存储桶移动到另一个存储桶/文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33616585/