You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Common commands
Set object metadata (setmeta)
Copy page
Download PDF
Set object metadata (setmeta)
You can use the setmeta command to set object metadata.​
Command syntax​
​
Linux/macOS
Windows
​
  • Set the metadata for an object​
​
./tosutil setmeta tos://bucket/key [-versionId=xxx] [-meta=aaa:bbb#ccc:ddd] [-contentType=xxx] [-contentDisposition=xxx] [-contentEncoding=xxx] [-contentLanguage=xxx] [-cacheControl=xxx] [-expires=xxx] [-fr] [-o=xxx] [-bt=xxx] [-e=xxx] [-re=xxx] [-i=xxx] [-k=xxx] [-t=xxx] [-conf=xxx]​
​
  • Set the metadata for objects in batches​
​
./tosutil setmeta tos://bucket/[prefix] -r [-j=1] [-meta=aaa:bbb#ccc:ddd] [-contentType=xxx] [-contentDisposition=xxx] [-contentEncoding=xxx] [-contentLanguage=xxx] [-cacheControl=xxx] [-expires=xxx] [-o=xxx] [-bt=xxx] [-e=xxx] [-re=xxx] [-i=xxx] [-k=xxx] [-t=xxx] [-conf=xxx]​
​
​
​
​
Description​
For descriptions of common optional parameters, see Global options.​
​
Parameter​
Type​
Description​
bucket​
String​
Bucket name.​
key​
String​
Object name.​
prefix​
String​
The prefix used for filtering objects in batch operations.​
-r​
Bool​
Set the metadata for objects in batches.​
-j​
Integer​
The maximum concurrency for setting the metadata for objects in batches. This value is set to the defaultJobs value in the configuration file by default.​
-versionId​
String​
The version ID of an object whose metadata is to be set.​
-meta​
String​
Sets the user-defined metadata for objects.​
-contentType​
String​
Sets the Content-Type metadata for objects.​
-contentDisposition​
String​
Sets the Content-Disposition metadata for objects.​
-contentEncoding​
String​
Sets the Content-Encoding metadata for objects.​
-contentLanguage​
String​
Sets the Content-Language metadata for objects.​
-cacheControl​
String​
Sets the Cache-Control metadata for objects.​
-expires​
String​
Sets the Expires metadata for objects, in the format of YYYYMMDDHHmmSS.​
-fr​
Bool​
Generate a result file when setting the metadata for an object.​
-o​
String​
The folder where result files are stored. The default location is specified in the configuration file as defaultOutputDir.​
-bt​
String​
The type of the bucket. The options are as follows:​
  • fns: A flat namespace (FNS) bucket.​
  • hns: A hierarchical namespace (HNS) bucket.​
If the bucket type is not specified, the default will be the type obtained from the bucket metadata.​
​
Examples​
Set the metadata for an object​
Use the following command to set the user-defined metadata for the object1.png object in the bucketname bucket to aaa:bbb#ccc: ddd.​
  • Command​
  • ​
    ./tosutil setmeta tos://bucketname/object1.png -meta aaa:bbb#ccc:ddd​
    ​
  • Output​
  • ​
    Start at 2022-10-27 08:30:54.714864 +0000 UTC​
    ​
    Set object metadata [object1.png] in the bucket [bucketname] successfully, cost [162], request id [d6c8485a41be2c6f635a41be-ac1424b7-1onyHu-SOM-cb-tos-bj]​
    ​
Set the metadata for objects in batches​
Use the following command to set the user-defined metadata for objects with the object prefix in the bucketname bucket to aaa:bbb#ccc: ddd.​
  • Command​
  • ​
    ./tosutil setmeta tos://bucketname/object -r -meta aaa:bbb#ccc:ddd​
    ​
  • Output​
  • ​
    Start at 2022-10-27 08:31:45.565285 +0000 UTC​
    ​
    [--------------------------------------------------] 100.00% tps:0.00 3/3 161ms​
    Succeed count is: 3 Failed count is: 0 ​
    Metrics [max cost:108 ms, min cost:36 ms, average cost:75.33 ms, average tps:18.63]​
    ​
    Task id is: cac32e78-55d1-11ed-936d-aa665a3c7f26​
    ​
​
Last updated: 2025.12.17 18:33:43