Object tagging

Last updated:2021-04-07 21:43:28

Kingsoft Cloud Standard Storage Service (KS3) enables you to classify the stored objects by using object tagging. You can configure lifecycle rules for objects with specified tags.

Note: Kingsoft Cloud charges you for using object tagging.

Object tagging uses a key-value pair to tag an object. You can add tags when you upload objects or add tags to existing objects.

A maximum of 10 tags can be set for each object. Each object tag must have a unique tag key.

Rules of setting a key:

  • A valid key can contain letters, digits, spaces, and special characters + - = . _ : /.

  • A valid key cannot start or end with a space or be left empty. It can be 1 to 128 characters in length and is case-sensitive.

  • Do not set a key to the reserved field of the system. Start a key with ksc: or kss:.

Rules of setting a value:

  • A valid value can contain letters, digits, spaces, and special characters + - = . _ : /.

  • A valid value cannot start or end with a space. It can be 1 to 256 characters in length and is case-sensitive.

  • Only the bucket owner and authorized users can read and write object tags.
  • Object tags are also replicated to the destination bucket during cross-region replication.

Scenarios

Object tags are not limited to folders. You can manage objects with specified tags in batches.

  • For example, you can configure lifecycle rules for objects with specified tags. When you upload objects, you can configure tagging for temporary objects that are periodically generated. After you configure lifecycle rules, these objects can be deleted based on the specified tags.

Instructions

  • API operations related to object tagging

    • PutObjectTagging: Configures tagging for an object. If an object already has tags, the existing tags are overwritten.
    • GetObjectTagging: Reads tags of an object.
    • DeleteObjectTagging: Deletes tags associated with an object.
    • PutObject: You can specify tags by using the x‑kss‑tagging request header when you upload an object.
    • PostObject: You can specify tags by using the tagging when you upload an object by using an HTML form.
    • InitiateMultipartUpload: You can specify tags by using the x‑kss‑tagging request header when you initialize a multipart upload task.
    • CopyObject: When you copy objects, you can use the x-kss-tagging-directive request header to specify whether to overwrite tags of source objects and use the x‑kss‑tagging request header to specify tags of destination objects.
    • PutObjcetFetch: You can specify tags of destination objects by using the x‑kss‑tagging request header when you pull objects and upload them to a specified KS3 bucket.
    • GetObject: If you have permissions to read object tags, the number of tags is included in the x‑kss‑tagging‑count response header.
    • HeadObject: If you have permissions to read object tags, the number of tags is included in the x‑kss‑tagging‑count response header.
  • Permissions

    Users, roles, and services that perform operations related to tags must have the following permissions:

    • GetObjectTagging: the permission to obtain object tags. If you have this permission, you can view the existing tags of an object.
    • PutObjectTagging: the permission to configure tagging for objects. If you have this permission, you can configure tagging for objects.
    • DeleteObjectTagging: the permission to delete object tags. If you have this permission, you can delete tags of an object.

Object tagging and lifecycle management

When you configure lifecycle rules, you can configure conditions for lifecycle rules to select subsets of objects for which to apply rules. You can specify a filter based on the object name prefixes, object tags, or both.

  • If you configure tag conditions, the rule applies only to objects that meet the tag key and value conditions.
  • If you configure an object name prefix and multiple object tags in one lifecycle rule, the rule applies only to objects that match the object name prefix and all of the configured object tags.

Example:

<LifecycleConfiguration>
  <Rule>
    <ID>1</ID>
    <Filter>
       <And>
          <Prefix>documents</Prefix>
          <Tag>
             <Key>age</Key>
             <Value>21</Value>
          </Tag>
          <Tag>
            <Key>name</Key>
            <Value>li</Value>
           </Tag>
       </And>
    </Filter>
    <Status>Enabled</Status>
    <Expiration>
        <Days>30</Days>
    </Expiration>
  </Rule>
  <Rule>
    <ID>2</ID>
      <Filter>
            <And>
               <Prefix>pic</Prefix>
               <Tag>
                  <Key>age</Key>
                  <Value>20</Value>
               </Tag>
            </And>
         </Filter>
    <Status>Enabled</Status>
    <Transition>
        <Days>60</Days>
        <StorageClass>Archive</StorageClass>
    </Transition>
  </Rule>
</LifecycleConfiguration>

In the preceding rules,

  • Objects whose names are prefixed with documents and whose tagging configurations are age=21 and name=li are deleted after being stored for 30 days.
  • The storage class of objects whose names are prefixed with pic and whose tagging configuration is age=20 is converted to Archive after the objects are stored for 60 days.

Note: For more information, see Lifecycle management.

Did you find the above information helpful?

Unhelpful
Mostly Unhelpful
A little helpful
Helpful
Very helpful

What might be the problems?

  • Insufficient
  • Outdated
  • Unclear or awkward
  • Redundant or clumsy
  • Lack of context for the complex system or functionality

More suggestions

0/200

Please give us your feedback.

Submitted

Thank you for your feedback.

问题反馈