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

Torch Object Storage

Copy page
Download PDF
List Objects
Listing Multi-Version Objects (Browser.js SDK)
Copy page
Download PDF
Listing Multi-Version Objects (Browser.js SDK)
This API is used to list multiversion objects in a bucket. This API returns a maximum of 1,000 multiversion objects in the bucket for each request. You can use request parameters to define the selection criteria for the objects to list.​
Notes​
  • To prevent your Volcengine account credentials (namely, AccessKey ID and AccessKey Secret) from being exposed in browser environments, it is strongly recommended that you perform TOS-related operations using temporary access credentials. For detailed instructions, please refer to Using STS Temporary AK/SK+Token to Access Volcengine TOS.​
  • Endpoint is the access domain name for TOS external services. For information on the Endpoints supported by TOS, please refer to Endpoint for Access Domain.​
  • Before listing versioned objects, you must have the tos:ListBucket permission. For more information, see IAM Policy Overview.​
Parameters​
​
Parameter​
Description​
prefix​
The prefix of the current query results.​
delimiter​
Character used to group object names.​
maxKeys​
Returns the maximum number of objects to be listed; the default value is 1000.​
Value range: (0, 1000]​
encodingType​
Encode the returned content and specify the encoding type.​
Default value: None​
keyMarker​
List the starting positions of multi-version objects. Objects are listed in alphabetical order after the specified start. This is typically the value of next_marker returned by the previous request.​
versionIdMarker​
Used in conjunction with KeyMarker, this sets the operation to return the list of version objects sorted lexicographically starting after the specified value. Obtain VersionIdMarker from the previous listing results.​
​
Sample Code​
A brief enumeration​
The following code is used to list up to 10 multi-version objects in the specified storage bucket.​
​
<!DOCTYPE html>​
<html lang="en">​
<head>​
<meta charset="UTF-8" />​
<title>Document</title>​
</head>​
​
<body>​
<button id="upload">Upload</button>​
<input id="file" type="file" />​
<script src="https://tos-public.volccdn.com/obj/volc-tos-public/@volcengine/tos-sdk@latest/browser/tos.umd.production.min.js"></script>​
<script src="./const.js"></script>​
<script type="text/javascript">​
const client = new TOS({​
region: yourRegion,​
endpoint: yourEndpoint,​
accessKeyId: yourAccessKey,​
accessKeySecret: yourSecretKey,​
stsToken: yourSecurityToken,​
bucket: examplebucket,​
});​
​
const listObjects = async () => {​
const data = await client.listObjectVersions({​
bucket: examplebucket,​
maxKeys: 10,​
});​
console.log('data', data.data);​
};​
​
listObjects();​
</script>​
</body>​
</html>​
​
List all objects with the specified prefix​
The following code is used to enumerate all versioned objects and delete markers under the specified prefix in the designated storage bucket.​
​
<!DOCTYPE html>​
<html lang="en">​
<head>​
<meta charset="UTF-8" />​
<title>Document</title>​
</head>​
​
<body>​
<button id="upload">Upload</button>​
<input id="file" type="file" />​
<script src="https://tos-public.volccdn.com/obj/volc-tos-public/@volcengine/tos-sdk@latest/browser/tos.umd.production.min.js"></script>​
<script type="text/javascript">​
const client = new TOS({​
region: yourRegion,​
endpoint: yourEndpoint,​
accessKeyId: yourAccessKey,​
accessKeySecret: yourSecretKey,​
stsToken: yourSecurityToken,​
bucket: examplebucket,​
});​
​
const listObjects = async () => {​
const data = await client.listObjectVersions({​
bucket: examplebucket,​
prefix: '1',​
});​
console.log('data', data.data);​
};​
​
listObjects();​
</script>​
</body>​
</html>​
​
List all objects​
The following code is used to enumerate all multi-version objects and delete markers within the specified bucket.​
​
<!DOCTYPE html>​
<html lang="en">​
<head>​
<meta charset="UTF-8" />​
<title>Document</title>​
</head>​
​
<body>​
<button id="upload">Upload</button>​
<input id="file" type="file" />​
<script src="https://tos-public.volccdn.com/obj/volc-tos-public/@volcengine/tos-sdk@latest/browser/tos.umd.production.min.js"></script>​
<script src="./const.js"></script>​
<script type="text/javascript">​
const client = new TOS({​
region: yourRegion,​
endpoint: yourEndpoint,​
accessKeyId: yourAccessKey,​
accessKeySecret: yourSecretKey,​
stsToken: yourSecurityToken,​
bucket: examplebucket,​
});​
​
const listObjects = async () => {​
const data = await client.listObjectVersions({​
bucket: examplebucket,​
});​
console.log('data', data.data);​
};​
​
listObjects();​
</script>​
</body>​
</html>​
​
​
Last updated: 2025.09.22 18:55:46