Boto3/S3:使用copy_object重命名对象 [英] Boto3/S3: Renaming an object using copy_object

查看:461
本文介绍了Boto3/S3:使用copy_object重命名对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python boto3重命名s3存储桶中的文件,我不清楚自己的参数.有人可以在这里帮助我吗?

I'm trying to rename a file in my s3 bucket using python boto3, I couldn't clearly understand the arguments. can someone help me here?

我打算将对象复制到新对象,然后删除实际对象.

What I'm planing is to copy object to a new object, and then delete the actual object.

我在这里发现了类似的问题,但是我需要使用boto3的解决方案.

I found similar questions here, but I need a solution using boto3.

推荐答案

我找到了另一个解决方案

I found another solution

s3 = boto3.resource('s3')
s3.Object('my_bucket','new_file_key').copy_from(CopySource='my_bucket/old_file_key')
s3.Object('my_bucket','old_file_key').delete()

这篇关于Boto3/S3:使用copy_object重命名对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆