Updated on 2025-08-22 GMT+08:00

Setting Object Properties

Function

You can use this command to set properties of an object or set properties of objects in batches by a specified object name prefix.

You can set storage classes only for buckets whose version is 3.0.

Command Line Structure

  • In Windows
    • Setting properties of a single object
      obsutil chattri obs://bucket/key [-meta=aaa:bbb#ccc:ddd] [-sc=xxx] [-acl=xxx] [-aclXml=xxx] [-versionId=xxx] [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
    • Setting properties of objects in batches
      obsutil chattri obs://bucket[/key] -r [-f] [-v] [-meta=aaa:bbb#ccc:ddd] [-sc=xxx] [-acl=xxx] [-aclXml=xxx] [-o=xxx] [-j=1] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
  • In Linux or macOS
    • Setting properties of a single object
      ./obsutil chattri obs://bucket/key [-meta=aaa:bbb#ccc:ddd] [-sc=xxx] [-acl=xxx] [-aclXml=xxx] [-versionId=xxx] [-fr] [-o=xxx] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
    • Setting properties of objects in batches
      ./obsutil chattri obs://bucket[/key] -r [-f] [-v] [-meta=aaa:bbb#ccc:ddd] [-sc=xxx] [-acl=xxx] [-aclXml=xxx] [-o=xxx] [-j=1] [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]

Examples

  • Take the Windows OS as an example, run the obsutil chattri obs://bucket-test/key -acl=public-read command to set the access permission to an object to public read.
    obsutil chattri obs://bucket-test/key -acl=public-read
    Start at 2024-09-30 08:17:15.5572914 +0000 UTC
    
    Set the acl of object [key] in the bucket [bucket-test] to [public-read] successfully, request id [04050000016836DDFA73B2B5320E2651]
  • Take the Windows OS as an example, run the obsutil chattri obs://bucket-test -r -f -acl=public-read command to set the access permission to all objects in the bucket to public read.
    obsutil chattri obs://bucket-test -r -f -acl=public-read
    Start at 2024-09-30 08:18:03.105373 +0000 UTC
    
    [------------------------------------------------] 100.00% tps:155.15 5/5 233ms
    Succeed count:   5         Failed count:    0
    Metrics [max cost:177 ms, min cost:53 ms, average cost:102.40 ms, average tps:20.41]
    Task id: 9d7f73ff-f747-4fdd-9b2a-815ba2dc3b07

Parameter Description

Parameter

Optional or Mandatory

Description

bucket

Mandatory

The name of the bucket to which an object belongs

key

Mandatory when setting properties of an object.

Optional when setting properties of objects in batches.

The name of the object whose properties are to be set, or the name prefix of objects whose properties are to be set in batches

If this parameter is left blank during batch operation, properties of all objects in the bucket are set.

meta

Optional (additional parameter)

The standard or user-defined metadata that can be specified for an object when setting properties of the object

  • Standard metadata includes Content-Type, Content-Encoding, Cache-Control, Content-Disposition, Content-Language and Expires.
  • User-defined metadata must be in the format of key:value. Multiple user-defined metadata items are separated by number signs (#), for example, key1:value1#key2:value2#key3:value3, which indicates that the object whose properties are set contains three groups of user-defined metadata: key1:value1, key2:value2, and key3:value3.

This parameter must be used together with direct.

direct

Optional (additional parameter)

The metadata operation indicator

The value can be:

  • REPLACE_NEW: The existing metadata value is replaced with a new one, the metadata lacking a value is assigned one, and the metadata not specified keeps unchanged.
  • REPLACE: The metadata is replaced with the header included in the current request and the metadata not specified is deleted.

This parameter must be used together with meta.

sc

Optional (additional parameter)

The storage class of an object. Possible values are:

  • standard: Standard storage class. It features low access latency and high throughput, and is applicable to storing frequently accessed data (multiple accesses per month) or data that is smaller than 1 MB.
  • warm: Infrequent Access storage class. It is ideal for storing infrequently accessed (less than 12 times a year) data, but when needed, the access has to be fast.
  • cold: Archive storage class. It provides secure, durable, and inexpensive storage for rarely-accessed (once a year) data.

For an object whose storage class is cold, restore the object first and then specify its storage class. To restore an object, see Restoring Objects from the Archive Storage.

acl

Optional (additional parameter)

The predefined access control policy of an object. Possible values are:

  • private
  • public-read
  • public-read-write
  • bucket-owner-full-control

aclXml

Optional (additional parameter)

The bucket's access control policy, in XML format. The format is as follows:

<AccessControlPolicy>
    <Owner>
        <ID>ownerid</ID>
    </Owner>
    <AccessControlList>
        <Grant>
            <Grantee>
                <ID>userid</ID>
            </Grantee>
            <Permission>[WRITE|WRITE_ACP|READ|READ_ACP|FULL_CONTROL]</Permission>
        </Grant>
        <Grant>
            <Grantee>
                <Canned>Everyone</Canned>
            </Grantee>
            <Permission>[WRITE|WRITE_ACP|READ|READ_ACP|FULL_CONTROL]</Permission>
        </Grant>
    </AccessControlList>
</AccessControlPolicy>
  • Owner: Optional. Specify the object owner's ID.
  • In AccessControlList, the Grant field contains the authorized users. Grantee specifies the IDs of authorized users. Canned specifies the authorized user group (currently, only Everyone is supported).
  • The following permissions can be granted:
    • WRITE: the write permission
    • WRITE_ACP: the write permission for the ACL
    • READ: the read permission
    • READ_ACP: the read permission for the ACL
    • FULL_CONTROL: the full control permission

Because angle brackets (<) and (>) are unavoidably included in the parameter value, you must use quotation marks to enclose them for escaping when running the command. Use single quotation marks for Linux or macOS and double quotation marks for Windows.

fs

Optional (additional parameter)

Whether the method of listing parallel file systems is applied. If you are listing parallel file systems, you are recommended to add this parameter.

  • After this parameter is enabled, marker and limit will be ignored. Then, the size of the bucket, parallel file system, or directory will be calculated.
  • This parameter is only supported by obsutil 5.5.12 and later.
  • With this method, the listing time required varies largely depending on the directory structures.

versionId

Optional when setting properties of an object (additional parameter)

The version ID of the object whose properties are to be set

fr

Optional when setting properties of an object (additional parameter)

Generates an operation result file when setting properties of an object.

f

Optional when setting properties of objects in batches (additional parameter)

Runs in force mode.

r

Mandatory when setting properties of objects in batches (additional parameter)

Sets properties of objects in batches based on a specified object name prefix.

v

Optional when setting properties of objects in batches (additional parameter)

Sets properties of versions of objects in batches based on a specified object name prefix.

o

Optional (additional parameter)

The folder that stores the result files. After the command is executed, result files (including success and failure files) will be created in the specified folder.

The default value is .obsutil_output, a subfolder in the user's home directory where obsutil commands are executed.

  • A result file should be named as follows: cp_{succeed | failed | warning}_report_time_TaskId.txt.
  • By default, the maximum size of a single result file is 30 MB. You can set the maximum size by configuring recordMaxLogSize in the configuration file.
  • By default, the maximum number of result files that can be retained is 1,024. You can set the maximum number by configuring recordBackups in the configuration file.
  • If there are multiple folders and files and you need to confirm the details of a failed task, refer to the failure result file chattri_failed_report_time_TaskId.txt in the result folder and the log files in the log path.

j

Optional when setting properties of objects in batches (additional parameter)

The maximum number of concurrent tasks for setting object properties in batches. The default value is the value of defaultJobs in the configuration file.

NOTE:

The value is ensured to be greater than or equal to 1.

config

Optional (additional parameter)

The user-defined configuration file for executing the current command. To learn the parameters that can be configured in this file, see Configuration Parameters.

e

Optional (additional parameter)

The endpoint

i

Optional (additional parameter)

The user's AK

k

Optional (additional parameter)

The user's SK

t

Optional (additional parameter)

The user's security token

Only one from acl, sc, or aclXml can be set for each command.

Response

Refer to Response for uploading an object.