By using AWS re:Post, you agree to the Terms of Use

CLI for renaming file in S3

0

I've renamed a S3 file with this CLI command:

aws s3 mv s3://bucket/folder/file1 s3://bucket/folder/file2

It took some seconds, so I presume it moved physically the file data. Is there a way to simply rename the file, without moving the data? It will make the command quicker for large files.

1 Answers
1
Accepted Answer

That is an interesting questions and I was looking at the possibilities for this. And I believe there is no better or easier way to rename an object other than what you have mentioned. There is no such option available to rename an object in either S3 CLI or s3api CLI. Further, in the AWS doc, it is suggested you have to copy an object in order to rename it.

I was also looking at possible options to somehow change some object metadata. You can see details about object metadata here. However, I don't see any metadata field in system metadata for the object or key name. Furthermore, the document explicitly mentions the following:

After you upload the object, you cannot modify object metadata. The only way to modify object metadata is to make a copy of the object and set the metadata.

So I believe copying the object is going to be your only option.

answered 5 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions