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

Torch Object Storage

Copy page
Download PDF
Share objects
List objects with the authorization code (share-ls)
Copy page
Download PDF
List objects with the authorization code (share-ls)
You can use the share-ls command with an authorization code to query objects in a bucket. The returned list of objects will be sorted in lexicographical order by name.​
Command syntax​
​
Linux/macOS
Windows
​
  • List objects or object versions using the authorization code directly​
​
./tosutil share-ls authorization_code [-key=xxx] [-s] [-d] [-v] [-marker=xxx] [-versionIdMarker==xxx] [-bf=xxx] [-limit=1] [-bt=xxx] [-et=xxx] [-conf=xxx]​
​
  • List objects or object versions using the authorization code path​
​
./tosutil share-ls file://authorization_code_file_url [-key=xxx] [-s] [-d] [-v] [-marker=xxx] [-versionIdMarker==xxx] [-bf=xxx] [-limit=1] [-bt=xxx] [-et=xxx] [-conf=xxx]​
​
​
​
​
Parameters​
For descriptions of common optional parameters, see Global options.​
​
Parameter​
Type​
Description​
authorization_code​
String​
The authorization code to be used.​
file://authorization_code_file_url​
String​
The authorization code path to be used.​
-key​
String​
The name of the object to be listed or the prefix of the objects to be listed.​
-s​
Bool​
Display results in a compact format.​
-d​
Bool​
List only the objects and subdirectories in the current directory and do not list them recursively.​
-v​
Bool​
List the versions of the objects in the bucket. If there are historical versions of the objects, the results will include the latest versions and the historical versions.​
-marker​
String​
Sets the starting position for listing the versions of the objects in the bucket. The results will include both the latest versions and the historical versions.​
-versionIdMarker​
String​
Sets the starting position for listing the object versions in the bucket. This parameter must be used in conjunction with the -marker parameter. The results will include all objects that come after this parameter in a lexicographical sort by object name and version ID.​
-bf​
Enum​
The display format for the byte count in the results when listing objects. Possible values:​
  • human-readable​
  • raw​
-limit​
Integer​
Sets the maximum number of returned resources, with a maximum value of 100,000.​
-bt​
String​
The type of the bucket. The options are as follows:​
  • fns: A flat namespace (FNS) bucket.​
  • hns: A hierarchical namespace (HNS) bucket.​
tip​
If the bucket type is not specified, tosutil will obtain the bucket type from the bucket metadata by default when listing objects. However, it will not recognize the bucket type when listing directories. This may cause the request to fail or return an error.​
-et​
Enum​
The encoding type for the object names returned. Currently, only url is supported.​
​
Examples​
List all objects in a bucket using the authorization code path and extraction code​
Use the following command to list all objects in the bucketname bucket. The authorization code path is /tmp/tosutil/authorization_code.​
  • Command​
  • ​
    ./tosutil share-ls file:///tmp/tosutil/authorization_code ​
    ​
  • Output​
  • ​
    Start at 2022-12-26 11:38:01.418696 +0000 UTC​
    ​
    Listing objects .​
    ​
    Object list:​
    key LastModified Size StorageClass ETag ​
    tos://bucketname/file/file1.png 2022-10-27T09:38:41Z 55.98KB STANDARD "d411110de34d37ce8ca0ad0e4dd3****"​
    ​
    tos://bucketname/file/file2.png 2022-10-27T09:38:56Z 74.96KB STANDARD "0216c42adc88aadf0078dd6e4139****"​
    ​
    tos://bucketname/file/file3.png 2022-10-27T09:39:05Z 499B STANDARD "8a5f4cb1a4d760e32f9ee51482c3****"​
    ​
    tos://bucketname/object1.png 2022-10-27T09:37:08Z 55.98KB STANDARD "d411110de34d37ce8ca0ad0e4dd3****"​
    ​
    tos://bucketname/object2.png 2022-10-27T09:37:15Z 56.76KB STANDARD "0eaa38cb4273c20a8ec8a6345aeb****"​
    ​
    tos://bucketname/object3.png 2022-10-27T09:37:21Z 74.96KB STANDARD "0216c42adc88aadf0078dd6e4139****"​
    ​
    Total size of bucket is: 319.14KB​
    File number is: 6​
    The authorized prefix is empty, all the content of bucket can be accessed​
    ​
List all versions of an object using the authorization code path and extraction code​
Use the following command to list all versions of the object1.png object in the bucketname bucket. The authorization code path is /tmp/tosutil/authorization_code.​
  • Command​
  • ​
    ./tosutil share-ls file:///tmp/tosutil/authorization_code -key=object1.png -v -s​
    ​
  • Output​
  • ​
    Start at 2022-10-27 09:40:42.574241 +0000 UTC​
    ​
    Listing versioning objects .​
    ​
    Versioning Object list:​
    tos://bucketname/object1.png​
    ​
    Total size of prefix [object1.png] is: 55.98KB​
    Versioning file number is: 1​
    DeleteMarker number is: 0​
    The authorized prefix is empty, all the content of bucket can be accessed​
    ​
List all objects within a bucket directory using the authorization code path and extraction code​
Use the following command to list objects in the file folder within the bucketname bucket. The authorization code path is /tmp/tosutil/authorization_code.​
  • Command​
  • ​
    ./tosutil share-ls file:///tmp/tosutil/authorization_code -key=file -s​
    ​
  • Output​
  • ​
    Start at 2022-10-27 09:42:54.896663 +0000 UTC​
    ​
    Listing objects .​
    ​
    Object list:​
    tos://bucketname/file/file1.png​
    tos://bucketname/file/file2.png​
    tos://bucketname/file/file3.png​
    ​
    Total size of prefix [file] is: 131.43KB​
    File number is: 3​
    The authorized prefix is empty, all the content of bucket can be accessed​
    ​
List all objects within a bucket directory using the authorization code and extraction code​
Run the following command to list the objects in the file folder within the bucketname bucket, using the authorization code for the file folder. The authorization code is xxx.​
  • Command​
  • ​
    ./tosutil share-ls xxx -key=file/ -s​
    ​
  • Output​
  • ​
    Start at 2022-10-27 09:42:54.896663 +0000 UTC​
    ​
    Listing objects .​
    ​
    Object list:​
    tos://bucketname/file/file1.png​
    tos://bucketname/file/file2.png​
    tos://bucketname/file/file3.png​
    ​
    Total size of prefix [file/] is: 131.43KB​
    File number is: 3​
    The authorized prefix is [file/]​
    ​
​
Last updated: 2025.12.17 18:33:45