Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Object Storage
    • All tutorials
      • Uploading an object
      • Multipart upload of an object
      • Get a list of bucket objects
      • Getting information about an object
      • Downloading an object
      • Restoring an object's version
      • Renaming and moving objects
      • Copying objects
      • Getting a public link to an object
      • Configuring an object lock
      • Deleting an object
      • Deleting all objects
      • Deleting a partially uploaded object
      • Editing an object's ACL
      • Managing object labels
      • Managing object custom metadata
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Uploading an object with metadata
  • Getting object metadata
  • Updating object metadata
  1. Step-by-step tutorials
  2. Objects
  3. Managing object custom metadata

Managing object custom metadata

Written by
Yandex Cloud
Improved by
Tania L.
Updated at May 5, 2025
  • Uploading an object with metadata
  • Getting object metadata
  • Updating object metadata

When uploading an object to Object Storage, you can provide custom metadata in the form of key-value pairs.

Uploading an object with metadataUploading an object with metadata

AWS CLI
API

If you do not have the AWS CLI yet, install and configure it.

In the terminal, run this command:

aws s3api put-object \
  --bucket <bucket_name> \
  --key <object_key> \
  --body <local_file_path> \
  --metadata "<key_1>"="<value_1>","<key_2>"="<value_2>" \
  --endpoint-url=https://storage.yandexcloud.net

Where:

  • --bucket: Name of the bucket you want to upload the object to.
  • --key: Bucket object key.
  • --body: Path to the local file you want to upload to the bucket.
  • --metadata: Custom metadata provided as comma-separated key-value pairs. Keys must only consist of ASCII characters. The value cannot exceed 2 KB.
  • --endpoint-url: Object Storage endpoint.

Use the upload S3 API method, e.g., via curl.

Use curl 8.3.0 or higher. For more information, see Example of using the AWS S3 API.

AWS_KEY_ID="<static_key_ID>"
AWS_SECRET_KEY="<secret_key>"
LOCAL_FILE="<local_file_path>"
BUCKET_NAME="<bucket_name>"
OBJECT_PATH="<object_key>"
META_KEY_1="<key_1>"
META_VALUE_1="<value_1>"
META_KEY_2="<key_2>"
META_VALUE_2="<value_2>"

curl \
  --request PUT \
  --user "${AWS_KEY_ID}:${AWS_SECRET_KEY}" \
  --aws-sigv4 "aws:amz:ru-central1:s3" \
  --upload-file "${LOCAL_FILE}" \
  --header "X-Amz-Meta-${META_KEY_1}: ${META_VALUE_1}" \
  --header "X-Amz-Meta-${META_KEY_2}: ${META_VALUE_2}" \
  --verbose \
  "https://storage.yandexcloud.net/${BUCKET_NAME}/${OBJECT_PATH}"

Where:

  • AWS_KEY_ID: Static access key ID.
  • AWS_SECRET_KEY: Secret key.
  • LOCAL_FILE: Path to the local file you want to upload to the bucket.
  • BUCKET_NAME: Name of the bucket you want to upload the object to.
  • OBJECT_PATH: Bucket object key.
  • META_KEY_1 and META_KEY_1: Custom metadata keys. Keys must only consist of ASCII characters.
  • META_VALUE_1 and META_VALUE_2: Custom metadata values. The value cannot exceed 2 KB.

Getting object metadataGetting object metadata

Yandex Cloud CLI
AWS CLI
API

If you do not have the Yandex Cloud CLI 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.

  1. See the description of the CLI command for getting object metadata:

    yc storage s3api head-object --help
    
  2. 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 |
    +------------------+----------------------+-------------+-----------------------+---------------------+
    
  3. Run this command:

    yc storage s3api head-object \
      --bucket <bucket_name> \
      --key <object_key>
    

    Where:

    • --bucket: Name of your bucket.
    • --key: Object key.

    Result:

    etag: '"d41d8cd98f00b204e9800998********"'
    request_id: 6428ce25********
    accept_ranges: bytes
    content_type: application/octet-stream
    last_modified_at: "2024-10-08T12:36:36Z"
    server_side_encryption: aws:kms
    sse_kms_key_id: abj497vtg3h0********
    

If you do not have the AWS CLI yet, install and configure it.

In the terminal, run this command:

aws s3api head-object \
  --bucket <bucket_name> \
  --key <object_key> \
  --endpoint-url=https://storage.yandexcloud.net

Where:

  • --bucket: Name of the bucket containing the object.
  • --key: Bucket object key.
  • --endpoint-url: Object Storage endpoint.

Use the getObjectMeta S3 API method, e.g., via curl.

Use curl 8.3.0 or higher. For more information, see Example of using the AWS S3 API.

AWS_KEY_ID="<static_key_ID>"
AWS_SECRET_KEY="<secret_key>"
BUCKET_NAME="<bucket_name>"
OBJECT_PATH="<object_key>"

curl \
  --head \
  --user "${AWS_KEY_ID}:${AWS_SECRET_KEY}" \
  --aws-sigv4 "aws:amz:ru-central1:s3" \
  "https://storage.yandexcloud.net/${BUCKET_NAME}/${OBJECT_PATH}"

Where:

  • AWS_KEY_ID: Static access key ID.
  • AWS_SECRET_KEY: Secret key.
  • BUCKET_NAME: Name of the bucket containing the object.
  • OBJECT_PATH: Bucket object key.

Updating object metadataUpdating object metadata

Warning

The existing custom metadata will be completely overwritten by the new metadata.

AWS CLI
API

If you do not have the AWS CLI yet, install and configure it.

In the terminal, run this command:

aws s3api copy-object \
  --bucket <bucket_name> \
  --key <object_key> \
  --copy-source <bucket_name>/<object_key> \
  --metadata "<key_1>"="<value_1>","<key_2>"="<value_2>" \
  --metadata-directive REPLACE \
  --endpoint-url=https://storage.yandexcloud.net

Where:

  • --bucket: Name of the bucket where you want to update the object metadata.
  • --key: Bucket object key.
  • --copy-source: Path to the object in <bucket_name>/<object_key> format.
  • --metadata: New custom metadata provided as comma-separated key-value pairs. Keys must only consist of ASCII characters. The value cannot exceed 2 KB.
  • --metadata-directive: Parameter specifying the need to overwrite the object metadata with new metadata.
  • --endpoint-url: Object Storage endpoint.

Use the copy S3 API method, e.g., via curl.

Use curl 8.3.0 or higher. For more information, see Example of using the AWS S3 API.

AWS_KEY_ID="<static_key_ID>"
AWS_SECRET_KEY="<secret_key>"
BUCKET_NAME="<bucket_name>"
OBJECT_PATH="<object_key>"
META_KEY_1="<key_1>"
META_VALUE_1="<value_1>"
META_KEY_2="<key_2>"
META_VALUE_2="<value_2>"

curl \
  --request PUT \
  --user "${AWS_KEY_ID}:${AWS_SECRET_KEY}" \
  --aws-sigv4 "aws:amz:ru-central1:s3" \
  --header "X-Amz-Copy-Source: /${BUCKET_NAME}/${OBJECT_PATH}" \
  --header "X-Amz-Metadata-Directive: REPLACE" \
  --header "X-Amz-Meta-${META_KEY_1}: ${META_VALUE_1}" \
  --header "X-Amz-Meta-${META_KEY_2}: ${META_VALUE_2}" \
  --verbose \
  "https://storage.yandexcloud.net/${BUCKET_NAME}/${OBJECT_PATH}"

Where:

  • AWS_KEY_ID: Static access key ID.
  • AWS_SECRET_KEY: Secret key.
  • BUCKET_NAME: Name of the bucket where you want to update the object metadata.
  • OBJECT_PATH: Bucket object key.
  • META_KEY_1 and META_KEY_1: New custom metadata keys. Keys must only consist of ASCII characters.
  • META_VALUE_1 and META_VALUE_2: New custom metadata values. The value cannot exceed 2 KB.

Was the article helpful?

Previous
Managing object labels
Next
Setting up hosting
© 2025 Direct Cursus Technology L.L.C.