簡體   English   中英

將文件從存儲桶移動到另一個存儲桶/文件夾

[英]Move files from bucket to another bucket/folder

我想將文件從存儲桶移動到同一個存儲桶/文件夾。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM