该接口用于列举桶中的未合并的对象,即列举分片上传任务。
列举分片上传任务前,您需要拥有 tos:ListBucketMultipartUploads
权限,具体操作,请参见 IAM 策略概述。
参数 | 描述 |
---|---|
delimiter | 对对象名称进行分组的字符。 |
encodingType | 对返回的内容进行编码并指定编码的类型。取值说明如下:
|
maxUploads | 返回分片上传任务的最大数量。默认值为 1000,取值范围为 (0,1000]。 |
prefix | 用于指定列举返回对象的前缀名称。 |
keyMarker | 列举分片上传任务的起始位置。设定从该值之后按字母排序返回对象列表。通常为上次请求返回的 |
uploadIDMarker | 与 |
以下代码用于列举 bucketName 存储桶中最多 1000 个未合并的分片上传任务。
import { TosClient, TosClientError, TosServerError } from '@volcengine/tos_harmonyos_sdk'; // 创建客户端 const client = new TosClient({ accessKeyId: "Provide your ak", accessKeySecret: "Provide your sk", securityToken: 'Provide your securityToken', region: "Provide your region", // 填写 Bucket 所在地域。以华北2(北京)为例,"Provide your region" 填写为 cn-beijing。 endpoint: "Provide your endpoint", // 填写域名地址 }); function handleError(error) { if (error instanceof TosClientError) { console.log('Client Err Msg:', error.message); console.log('Client Err Stack:', error.stack); } else if (error instanceof TosServerError) { console.log('Request ID:', error.requestId); console.log('Response Status Code:', error.statusCode); console.log('Response Header:', error.headers); console.log('Response Err Code:', error.code); console.log('Response Err Msg:', error.message); } else { console.log('unexpected exception, message: ', error); } } async function main() { try { // 获取 bucket 中最多 1000 个未完成任务 const res = await client.listMultipartUploads({ Bucket: bucketName, MaxUploads: 1000 }); console.log('Uploads.length:', res.Uploads.length); for (const upload of res.Uploads) { console.log('Object Key:', upload.Key); console.log('UploadID:', upload.UploadId); console.log('Owner:', upload.Owner); console.log('StorageClass:', upload.StorageClass); } } catch (error) { handleError(error); } } main()
以下代码用于列举 bucketName 存储桶 prefix 前缀的未合并的所有分片上传任务。
import { TosClient, TosClientError, TosServerError } from '@volcengine/tos_harmonyos_sdk'; // 创建客户端 const client = new TosClient({ accessKeyId: "Provide your ak", accessKeySecret: "Provide your sk", securityToken: 'Provide your securityToken', region: "Provide your region", // 填写 Bucket 所在地域。以华北2(北京)为例,"Provide your region" 填写为 cn-beijing。 endpoint: "Provide your endpoint", // 填写域名地址 }); function handleError(error) { if (error instanceof TosClientError) { console.log('Client Err Msg:', error.message); console.log('Client Err Stack:', error.stack); } else if (error instanceof TosServerError) { console.log('Request ID:', error.requestId); console.log('Response Status Code:', error.statusCode); console.log('Response Header:', error.headers); console.log('Response Err Code:', error.code); console.log('Response Err Msg:', error.message); } else { console.log('unexpected exception, message: ', error); } } async function main() { try { // 列举指定前缀的所有多版本对象 const prefix = '*** Provide your object key prefix ***'; let keyMarker: string= '' let uploadIdMarker: string = ''; while (true) { const res = await client.listMultipartUploads({ Bucket: bucketName, MaxUploads: 1000, Prefix: prefix, KeyMarker: keyMarker, UploadIdMarker: uploadIdMarker, }); console.log('Uploads.length:', res.Uploads.length); for (const upload of res.Uploads) { console.log('Object Key:', upload.Key); console.log('UploadID:', upload.UploadId); console.log('Owner:', upload.Owner); console.log('StorageClass:', upload.StorageClass); } if (!res.IsTruncated) { break; } keyMarker = res.NextKeyMarker ?? ''; uploadIdMarker = res.NextUploadIdMarker ?? ''; } } catch (error) { handleError(error); } } main()
以下代码用于列举 bucketName **** 存储桶未合并的所有分片上传任务。
import { TosClient, TosClientError, TosServerError } from '@volcengine/tos_harmonyos_sdk'; // 创建客户端 const client = new TosClient({ accessKeyId: "Provide your ak", accessKeySecret: "Provide your sk", securityToken: 'Provide your securityToken', region: "Provide your region", // 填写 Bucket 所在地域。以华北2(北京)为例,"Provide your region" 填写为 cn-beijing。 endpoint: "Provide your endpoint", // 填写域名地址 }); function handleError(error) { if (error instanceof TosClientError) { console.log('Client Err Msg:', error.message); console.log('Client Err Stack:', error.stack); } else if (error instanceof TosServerError) { console.log('Request ID:', error.requestId); console.log('Response Status Code:', error.statusCode); console.log('Response Header:', error.headers); console.log('Response Err Code:', error.code); console.log('Response Err Msg:', error.message); } else { console.log('unexpected exception, message: ', error); } } async function main() { try { let keyMarker: string= '' let uploadIdMarker: string = ''; while (true) { const res = await client.listMultipartUploads({ Bucket: bucketName, MaxUploads: 1000, KeyMarker: keyMarker, UploadIdMarker: uploadIdMarker, }); console.log('Uploads.length:', res.Uploads.length); for (const upload of res.Uploads) { console.log('Object Key:', upload.Key); console.log('UploadID:', upload.UploadId); console.log('Owner:', upload.Owner); console.log('StorageClass:', upload.StorageClass); } if (!res.IsTruncated) { break; } keyMarker = res.NextKeyMarker ?? ''; uploadIdMarker = res.NextUploadIdMarker ?? ''; } } catch (error) { handleError(error); } } main()