The set-meta command is used to set metadata for objects that have been uploaded.
Command syntax
./ossutil set-meta oss://bucket[/prefix] [header:value#header:value...] [--update] [--delete] [-r] [-f] [-c file]
Examples
- Configure the metadata of a specified object
./ossutil set-meta oss://bucket1/path/object x-oss-object-acl:private
If the --update and --delete options are not specified, this command replaces the existing metadata with the specified metadata. If the
[header:value#header:value...]
option is not specified, the values of headers that cannot be deleted, such as headers without the X-Oss-meta- prefix, will remain unchanged. Other metadata will be deleted.Note Headers are case-insensitive, whereas values are case-sensitive. The list of headers you can set for objects is as follows:Headers: Expires(time.RFC3339:2006-01-02T15:04:05Z07:00) X-Oss-Object-Acl Origin X-Oss-Storage-Class Content-Encoding Cache-Control Content-Disposition Accept-Encoding X-Oss-Server-Side-Encryption Content-Type Headers with the X-Oss-Meta- prefix
For more information, see Manage Object Meta.
- Configure the metadata of all objects that have a specified prefix
./ossutil set-meta oss://bucket1/path/ Cache-Control:no-cache#x-oss-object-acl:private -r
If the -r option is specified, the metadata of multiple objects with the specified prefix will be configured. When an error occurs during an operation on an object, ossutil records the error information of the object in a report object and then continues to perform the operation on other objects. The information of objects that were processed will not be recorded in the report object. Separate multiple metadata items with number signs (#).
- Update the metadata of a specified object
./ossutil set-meta oss://bucket1/path/object x-oss-object-acl:private --update
The command only updates the specified header of the specified object as the input value. The header value can be null. The other metadata of the specified object remains unchanged. The --update (abbreviated as -u) and --delete options cannot be specified together.
- Delete the metadata of a specified object
./ossutil set-meta oss://bucket1/obj1 X-Oss-Meta-delete --delete
If the --delete option is specified, ossutil deletes the specified object header and the value becomes null. The other metadata of the object remains unchanged. This option is not valid for headers that cannot be deleted, such as headers without the X-Oss-Meta- prefix. The --update and --delete options cannot be specified together.
- Configure the metadata of multiple objects with specified conditions
When configuring metadata, you can use --include and --exclude to select objects that meet the specified conditions. For more information, see cp.
- Set all objects with a .jpg extension to the Infrequent Access (IA) storage class
./ossutil64 set-meta oss://my-bucket/path X-Oss-Storage-Class:IA --include "*.jpg" -u -r
- Set all objects that contain abc in their names and are not in JPG or TXT format to the Standard storage class
./ossutil set-meta oss://my-bucket/path X-Oss-Storage-Class:Standard --include "*abc*" --exclude "*.jpg" --exclude "*.txt" -u -r
- Set all objects with a .jpg extension to the Infrequent Access (IA) storage class
- Configure the metadata of a specified version of an object in a versioning-enabled
bucket
To use the --version-id option, you must run the ls --all-versions command to obtain all available versions of the object../ossutil set-meta oss://bucket1/test.jpg X-Oss-Storage-Class:Standard --version-id CAEQARiBgID8rumR2hYiIGUyOTAyZGY2MzU5MjQ5ZjlhYzQzZjNlYTAyZDE3MDRk
Note The--version-id
option can only be used for objects in versioning-enabled buckets. For more information about the command used to enable versioning on a bucket, see bucket-versioning.
Common options
Option | Description |
---|---|
-u, --update | Updates the metadata of a specified object. |
--delete | Deletes the metadata of a specified object. |
-r, --recursive | Recursively performs operations on objects in a bucket. If this option is specified, the command will perform operations on all objects in a bucket that meet the specified conditions. If this option is not specified, the command will only perform operations on a single specified object. |
-f, --force | Specifies whether to force an operation without prompting the user for confirmation. |
--include | Includes objects that match a specified string, such as *.jpg. |
--exclude | Excludes objects that match a specified string, such as *.txt. |
--encoding-type | Specifies the method used to encode the object name. If this option is specified, this value must be url. If this option is not specified, the object name is not encoded. Bucket names cannot be URL-encoded. |
-j, --jobs | Specifies the number of concurrent operations performed across multiple objects. Valid values: 1 to 10000. Default value: 3. |
-L, --language | Specifies the language ossutil uses. Valid values: CH and EN. Default value: CH. To set this option to CH, ensure that your system supports UTF-8 encoding. |
--output-dir | Specifies the directory in which output objects are located. Output objects include report objects generated due to errors that occur when you use the cp command to copy multiple objects. For more information about the report objects, see the help information of the cp command. The default value is the ossutil_output directory in the current directory. |
--loglevel | Specifies the log level. The default value is null, indicating that no log files are
generated. Valid values:
|
--version-id | Specifies the version ID of an object in a versioning-enabled bucket. |
--retry-times | Specifies the number of times an operation is retried if the operation fails. Valid values: 1 to 500. Default value: 10. |
--proxy-host | Specifies the URL of the proxy server. HTTP, HTTPS, and SOCKS5 proxies are supported. An example of the URL is http://120.79. **.**:3128 or socks5://120.79. **. **:1080. |
--proxy-user | Specifies the username for the proxy server. The default value is null. |
--proxy-pwd | Specifies the password for the proxy server. The default value is null. |