Renaming and moving an object
To work with objects in an encrypted bucket, a user or service account must have the following roles for the encryption key in addition to the storage.configurer
role:
kms.keys.encrypter
: To read the key, encrypt and upload objects.kms.keys.decrypter
: To read the key, decrypt and download objects.kms.keys.encrypterDecrypter
: This role includes thekms.keys.encrypter
andkms.keys.decrypter
permissions.
For more information, see Key Management Service service roles.
Renaming
If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
See the description of the CLI command for renaming an object in a bucket:
yc storage s3 mv --help
-
Get a list of buckets in the default folder:
yc storage bucket list
Result:
+------------------+----------------------+-------------+-----------------------+---------------------+ | NAME | FOLDER ID | MAX SIZE | DEFAULT STORAGE CLASS | CREATED AT | +------------------+----------------------+-------------+-----------------------+---------------------+ | first-bucket | b1gmit33ngp6******** | 53687091200 | STANDARD | 2022-12-16 13:58:18 | +------------------+----------------------+-------------+-----------------------+---------------------+
-
Run this command:
yc storage s3 mv \ s3://<bucket_name>/<object_key> \ s3://<bucket_name>/<new_object_key>
Result:
move: s3://my-bucket/object.txt to s3://my-bucket/renamed-object.txt
-
If you do not have the AWS CLI yet, install and configure it.
-
To rename an object, run this command:
aws --endpoint-url=https://storage.yandexcloud.net/ \ s3 mv s3://<bucket_name>/<object_key> s3://<bucket_name>/<new_object_key>
Where:
--endpoint-url
: Object Storage endpoint.s3 mv
: Command to rename or move an object. To rename an object, in the first part of the command, provide the bucket name and the current key of the object you want to rename, and in the second part, the bucket name and the new object key.
Result:
move: s3://<bucket_name>/<object_key> to s3://<bucket_name>/<new_object_key>
For more information about the aws s3 mv
command, see this article
Moving
If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.
The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
Read the description of the CLI command for moving an object:
yc storage s3 mv --help
-
Get a list of buckets in the default folder:
yc storage bucket list
Result:
+------------------+----------------------+-------------+-----------------------+---------------------+ | NAME | FOLDER ID | MAX SIZE | DEFAULT STORAGE CLASS | CREATED AT | +------------------+----------------------+-------------+-----------------------+---------------------+ | first-bucket | b1gmit33ngp6******** | 53687091200 | STANDARD | 2022-12-16 13:58:18 | +------------------+----------------------+-------------+-----------------------+---------------------+
-
Run this command:
yc storage s3 mv \ s3://<source_bucket_name>/<object_key> \ s3://<target_bucket_name>/<object_key>
Result:
move: s3://my-bucket/object.txt to s3://new-bucket/object.txt
-
If you do not have the AWS CLI yet, install and configure it.
-
To move an object, e.g., from one bucket to another, run this command:
aws --endpoint-url=https://storage.yandexcloud.net/ \ s3 mv s3://<source_bucket_name>/<object_key> s3://<target_bucket_name>/<object_key>
Where:
--endpoint-url
: Object Storage endpoint.s3 mv
: Command to rename or move an object. To move an object, in the first part of the command, provide the source bucket name and the key of the object you want to move, and in the second part, the target bucket name and the object key.
Result:
move: s3://<source_bucket_name>/<object_key> to s3://<target_bucket_name>/<object_key>
For more information about the aws s3 mv
command, see this article
In Object Storage, directories are simulated using key prefixes. To move an object from one directory to another, rename its key prefix.
You can also use supported tools, such as a file browser, to rename and move objects.