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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南