The set-props command sets object properties, including access permissions, storage classes, metadata, and tags.
Precautions
The set-props command calls different API operations depending on the object property that you modify. Ensure that you have the required permissions. For example, calling the PutObjectAcl API operation requires the oss:PutObjectAcl permission. The specific API operations that are called are as follows:
To modify only the object access control list (ACL): The command calls the
PutObjectAclAPI operation.To modify only the object tags: The command calls the
PutObjectTaggingAPI operation. If the tag modification instruction involves updating existing tags, such as an incremental addition, the system first calls theGetObjectTaggingAPI operation to retrieve the original tags.To modify the object storage class or metadata: This operation rewrites the object. The command calls the
CopyObjectAPI operation or uses the multipart copy flow (InitiateMultipartUpload->UploadPartCopy->CompleteMultipartUpload).To modify multiple properties at the same time: The command selects the most efficient combination of API operations. For example:
To modify both object permissions and tags: The command calls
PutObjectAclandPutObjectTagging.To modify both object permissions and storage class: The command directly calls the
CopyObjectAPI operation or the multipart copy API operations (InitiateMultipartUpload->UploadPartCopy->CompleteMultipartUpload) to update the permissions and storage class at the same time.
Command format
ossutil set-props oss://bucket[/prefix] [flags]Parameter | Type | Description |
--acl | string | The access control list (ACL) of the object. Valid values:
|
--bigfile-threshold | int | The threshold to enable multipart upload, download, or copy for large files. The default value is 104857600 bytes. |
--cache-control | string | Specifies the web page caching behavior when the object is downloaded. |
--content-disposition | string | Specifies how the object is displayed. |
--content-encoding | string | Specifies the encoding format of the object. |
--content-type | string | The content type of the object. |
-d, --dirs | / | Returns the files and subdirectories in the current directory. It does not recursively display all files in all subdirectories. |
--encoding-type | string | The encoding type of the input object name or file name. Valid value: url. |
--end-with | string | Sorts objects alphabetically and returns objects that are before or at the specified value. |
--exclude | stringArray | The rules to exclude paths or file names. |
--exclude-from | stringArray | Reads exclusion rules from a rule file. |
--expires | string | Specifies the absolute expiration time for the cached content. |
--files-from | stringArray | Reads a list of source file names from a file. Empty lines or commented lines are ignored. |
--files-from-raw | stringArray | Reads a list of source file names from a file. |
--filter | stringArray | The rules to filter paths or file names. |
--filter-from | stringArray | Reads filtering rules from a rule file. |
-f, --force | / | Forces the operation without a confirmation prompt. |
--include | stringArray | The rules to include paths or file names. |
--include-from | stringArray | Reads inclusion rules from a rule file. |
-j, --job | int | The number of concurrent tasks. The default value is 3. Important This parameter takes effect only when you specify the |
--list-objects | / | Uses the ListObjects API operation to list objects. |
--max-size | SizeSuffix | The maximum size of a file to transfer. The default unit is byte. You can use a suffix: B, K, M, G, T, or P. 1 K (KiB) = 1024 B. |
--metadata | strings | Specifies the user metadata of the object in the key=value format. Example: --metadata test=value,test1=value1. |
--metadata-directive | string | The instruction to modify metadata. Valid values:
|
--metadata-exclude | stringArray | The rules to exclude object metadata. |
--metadata-filter | stringArray | The rules to filter object metadata. |
--metadata-filter-from | stringArray | Reads object metadata filtering rules from a rule file. |
--metadata-include | stringArray | The rules to include object metadata. |
--min-age | Duration | Sets properties only for files modified before the specified time interval. The default unit is second. You can use a unit suffix, such as 1h for 1 hour. Note
|
--max-age | Duration | Sets properties only for files modified within the specified time interval. The default unit is second. You can use a unit suffix, such as 1h for 1 hour. Note
|
--min-mtime | Time | Sets properties only for files modified after the specified time. The time must be in UTC format. For example, 2006-01-02T15:04:05. Note
|
--max-mtime | Time | Sets properties only for files modified before the specified time. The time must be in UTC format. For example, 2006-01-02T15:04:05. |
--min-size | SizeSuffix | The minimum size of a file to transfer. The default unit is byte. You can use a suffix: B, K, M, G, T, or P. 1 K (KiB) = 1024 B. |
--no-progress | / | Does not display the progress bar. |
--page-size | int | The maximum number of objects to list on each page during batch processing. The default value is 1000. The value can range from 1 to 1000. |
--parallel | int | The number of concurrent tasks for operations on a single file. |
--part-size | SizeSuffix | The part size. By default, ossutil calculates an appropriate part size based on the file size. The value must be between 100 KiB and 5 GiB. |
-r, --recursive | / | Performs the operation recursively. When you specify this option, the command is applied to all matching objects in the bucket. Otherwise, the command is applied only to the object specified by the path. |
--request-payer | string | The payment method for the request. Set this parameter if you use the pay-by-requester mode. Valid value: requester. |
--start-after | string | Sorts objects alphabetically and returns objects that are after the specified value. |
--storage-class | string | The storage class of the object. Valid values:
|
--tagging | strings | Specifies the tags of the object in the key=value format. Example: --tagging tag1=value1,tag2=value2. |
--tagging-directive | string | The instruction to modify tags. Valid values:
|
--version-id | string | The version ID of the object. |
--list-format | string | The format of the list file. Valid values: plain, inventory. |
--list-manifest-from | string | Reads the description of the list file format from a file. This parameter is required when the list file format is `inventory`. |
For more information, see Command-line options.
Examples
Set the access permissions of an object to private.
ossutil set-props oss://examplebucket/exampleobject.txt --acl privateSet the storage class of an object to Archive Storage.
ossutil set-props oss://examplebucket/exampleobject.txt --storage-class ArchiveFor objects that have the .txt extension, change the content-type to text/plain.
ossutil set-props oss://bucket/prefix --content-type text/plain --include "*.txt" --metadata-directive update -rSet the tags of an object.
ossutil set-props oss://examplebucket/exampleobject.txt --tagging tag1=value1 --tagging-directive updateSet object properties from a list file.
NoteEach line in the list file represents an object and uses the OSS path format `oss://{bucket}/{key}`. For example, the list.txt file contains the following content:
oss://examplebucket/key1 oss://examplebucket/key2ossutil set-props list://list.txtSet object properties from a manifest file.
NoteAfter you run an inventory task, a `csv.gz` file and a `manifest.json` file are generated in the inventory results. You need to use these two files to set object properties from a manifest file.
ossutil set-props list://ca8007fc-4123-493e-9a01-dd1511fbac54.csv.gz --list-format inventory --list-manifest-from manifest.json