[英]How to move files in Google Cloud Storage from one bucket to another bucket by Python
[英]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.