CLI for renaming file in S3

1

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.

profile picture
Corral
已提问 2 年前6006 查看次数
1 回答
1
已接受的回答

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.

已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则