Boto3/S3: Renaming an object using copy_object

后端 未结 3 1314
鱼传尺愫
鱼传尺愫 2020-12-12 23:35

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

3条回答
  •  眼角桃花
    2020-12-13 00:21

    You cannot rename objects in S3, so as you indicated, you need to copy it to a new name and then deleted the old one:

    client.copy_object(Bucket="BucketName", CopySource="BucketName/OriginalName", Key="NewName")
    client.delete_object(Bucket="BucketName", Key="OriginalName")
    

提交回复
热议问题