I’m looking for advice on managing files and folders in Amazon S3. Specifically, is there a built-in function or best practice for renaming files and folders within S3?
I’m expecting to learn about any built-in functions or best practices for renaming files and folders in Amazon S3.
2
Answers
With
awscli
or directly from AWS Console, to rename an object or multi-ones, you need to perform the move action.https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/mv.html
For specific application, you need to check if it supports AWSSDK and allows you to perform above actions or you may need to build a custom function by your own.
It is not possible to rename objects in Amazon S3. Instead, they must be copied and then the original object must be deleted.
The AWS CLI
aws s3 mv
command actually does the Copy and Move command for you.Folders do not actually exist in Amazon S3. Instead, each object has a Key (filename) that includes the full path of the object. Therefore, it is not possible to ‘rename a folder’ since the folder doesn’t exist!
However, the AWS CLI can perform an equivalent function with
aws s3 mv --recursive
, which will move all objects in the indicated path.