Updated on 2025-07-01 GMT+08:00

Adding Tags to an Object

Tag Rules

OBS offers object tags for you to classify objects in buckets. You can tag an object when you upload it to a bucket or after it is stored in the bucket.

An object tag is a key-value pair. To use tags, follow the rules below:

  • An object can have up to 10 tags.
  • A tag key:
    • Must be unique if there are multiple tags specified for an object.
    • Can be 36 characters long at most and cannot contain the following special characters: =*<>\,|/. It must be case sensitive and unique, and cannot start or end with a space. It cannot be left blank.
  • A tag value:
    • Can be 255 characters long at most and cannot contain the following special characters: =*<>\,|/. It must be case sensitive and cannot start or end with a space. It can be left blank.

Precautions

  • Object tags are now during open beta testing and can be used for free. Once the testing period is over, you will be billed for using them.
  • To read or write object tags, you must be the object owner or have required permissions. Such permissions can be granted using bucket policies.
  • During cross-region replication, tags of source objects are not copied.
  • Tags cannot be added to files in parallel file systems.
  • Currently, object tags cannot be used in IAM permissions or bucket policies.

Scenarios

Specifying object tags in a lifecycle rule

In a lifecycle configuration, you can specify filter conditions to identify the objects which the lifecycle rule applies to. A filter can be defined based on an object name prefix, an object tag, or both. For example, you can configure a lifecycle rule to delete objects with prefix texta/ and tag key1/value1 or key2/value2 120 days after their creation.
<LifecycleConfiguration>
    <Rule>
        <ID>sample-rule</ID>  
        <Filter>
            <And>
                <Prefix>texta/</Prefix>
                <Tag>
                    <Key>key1</Key>
                    <Value>value1</Value>
                </Tag>
                <Tag>
                    <Key>key2</Key>
                    <Value>value2</Value>
                </Tag>
            </And>
        </Filter>
        <Status>Enabled</Status>
        <Expiration>
            <Days>120</Days>
        </Expiration>
    </Rule>
</LifecycleConfiguration>

Ways to Configure Object Tags

You can use OBS Console or APIs to configure object tags.

Related Operations

In the tag list, click Edit to change the tag value or click Delete to remove the tag.