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

前端 未结 6 1160
温柔的废话
温柔的废话 2021-02-19 01:27

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:14

    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.

提交回复
热议问题