How to clone a key in Amazon S3 using Python (and boto)?

前端 未结 6 2103
清歌不尽
清歌不尽 2021-02-19 02:00

I have a file contained in a key in my S3 bucket. I want to create a new key, which will contain the same file. Is it possible to do without downloading that file? I\'m looking

6条回答
  •  太阳男子
    2021-02-19 02:22

    Although nobody asked, I thought it might be relevant to show how to do this with simples3:

    >>> b.copy("my_bucket/file.txt", "file_copy.txt", acl="public")
    

    I'm not sure what Boto does here, but it's worth noting that the permissions (ACL) will not be copied by S3, it will be reset to "private" if nothing else is specified. To copy the ACL, you have to ask for it first.

提交回复
热议问题