Downloading 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
: Includes thekms.keys.encrypter
andkms.keys.decrypter
permissions.
For more information, see Key Management Service service roles.
Note
- In the management console
, select the folder. - Select Object Storage.
- Select the bucket from which you want to download an object.
- Next to the object you want to download, click
and select Download.
If you do not have the AWS CLI yet, install and configure it.
Downloading a single object
aws s3 cp \
--endpoint-url=https://storage.yandexcloud.net \
s3://<bucket_name>/<object_key> \
<local_path>
Where:
--endpoint-url
: Object Storage endpoint.<bucket_name>
: Name of the bucket you want to download the object from.<object_key>
: Key of the object you want to download.<local_path>
: Path to the folder to save the downloaded object to. e.g.,~/downloads/
.
Downloading a directory (all objects with a specified prefix)
For more information about folders in Object Storage, see Directory.
aws s3 cp \
--endpoint-url=https://storage.yandexcloud.net \
--recursive \
s3://<bucket_name>/<prefix>/ \
<local_path>
Where:
--endpoint-url
: Object Storage endpoint.--recursive
: Parameter for downloading all objects with the specified prefix.<bucket_name>
: Name of the bucket you want to download the objects from.<prefix>
: Prefix (folder) of the objects you want to download, e.g.,test/folder
.<local_path>
: Path to the folder to save the downloaded objects to, e.g.,~/downloads/
.
Downloading all objects from a bucket
aws s3 cp \
--endpoint-url=https://storage.yandexcloud.net \
--recursive \
s3://<bucket_name> \
<local_path>
Where:
--endpoint-url
: Object Storage endpoint.--recursive
: Parameter for downloading all objects from the bucket to a local folder.<bucket_name>
: Name of the bucket you want to download the objects from.<local_path>
: Path to the folder to save the downloaded objects to, e.g.,~/downloads/
.
aws s3 cp
is a high-level command with limited functionality. For more information, see the AWS CLI reference
You can download bucket objects selectively using the aws s3api
command and a JMESPath query template. To download objects using a query template, run this command:
-
Bash:
aws s3api list-objects \ --endpoint-url https://storage.yandexcloud.net \ --bucket <bucket_name> \ --query '<query>' \ --output text | xargs -I {} aws s3api get-object --endpoint-url https://storage.yandexcloud.net --bucket <bucket_name> --key {} <local_path>{}
Where:
--endpoint-url
: Object Storage endpoint.--bucket
: Name of the bucket you want to download the objects from.--query
: Query in JMESPath format.<local_path>
: Path to the folder to save the downloaded objects to, e.g.,~/downloads/
.
Here is an example of a command that downloads all objects whose filenames start with
date-20231002
from thesample-bucket
bucket to the~/downloads/
local folder:aws s3api list-objects \ --endpoint-url https://storage.yandexcloud.net \ --bucket sample-bucket \ --query 'Contents[?starts_with(Key, `date-20231002`) == `true`].[Key]' \ --output text | xargs -I {} aws s3api get-object --endpoint-url https://storage.yandexcloud.net --bucket sample-bucket --key {} ~/downloads/{}
-
PowerShell:
Foreach($x in (aws s3api list-objects ` --endpoint-url https://storage.yandexcloud.net ` --bucket <bucket_name> ` --query '<query>' ` --output text)) ` {aws s3api get-object --endpoint-url https://storage.yandexcloud.net --bucket <bucket_name> --key $x <local_path>$x}
Where:
--endpoint-url
: Object Storage endpoint.--bucket
: Name of the bucket you want to download the objects from.--query
: Query in JMESPath format.<local_path>
: Path to the folder to save the downloaded objects to, e.g.,d:\downloads\
.
Here is an example of a command that downloads all objects whose filenames start with
date-20231002
from thesample-bucket
bucket to thed:\downloads\
local folder:Foreach($x in (aws s3api list-objects ` --endpoint-url https://storage.yandexcloud.net ` --bucket sample-bucket ` --query 'Contents[?starts_with(Key, `date-20231002`) == `true`].[Key]' ` --output text)) ` {aws s3api get-object --endpoint-url https://storage.yandexcloud.net --bucket sample-bucket --key $x d:\downloads\$x}
To download an object, use the get S3 API method.