Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boto3/S3: Renaming an object using copy_object

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.

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

like image 246
MikA Avatar asked Sep 10 '15 12:09

MikA


1 Answers

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() 
like image 117
MikA Avatar answered Oct 06 '22 23:10

MikA