tencent cloud

Smart Media Hosting

Delete Files in Batches

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2026-01-07 10:49:06

Introduction

This document provides the API overview for deleting files in batches and SDK example code.
API
Operation Description
Delete Files in Batches

SDK API Reference

For specific parameters and method descriptions of all APIs in the SDK, please see SDK API Reference.

Batch Deletion

Feature Overview

Delete directories or files in batches
When deleting projects asynchronously, return HTTP 202 Accepted. When deleting projects synchronously, return HTTP 200 OK (all execution successful) or HTTP 207 Multi-Status (part or all execution failed).

Batch Deleting Sample Code

Start batch deletion
QCloudSMHBatchDeleteRequest *req = [QCloudSMHBatchDeleteRequest new];
req.libraryId = @"libraryId";
req.spaceId = @"spaceId";
req.userId = @"userId";
req.spaceOrgId = @"spaceOrgId";
req.batchInfos = @[];
[req setFinishBlock:^(QCloudSMHBatchResult *result, NSError * _Nullable error) {
if it is a sync task, obtain the task status from the http status code
QCloudSMHBatchTaskStatus status = QCloudSMHBatchTaskStatusTypeFromStatus([result __originHTTPURLResponse__].statusCode);
result.status = status;
if(status != QCloudSMHBatchTaskStatusWating || error){
// End when task status is not wait or there is an error
if(self.finishBlock){
self.finishBlock(result, error);
}
}else{
// Use the returned taskid to poll task status
self.taskId = result.taskId;
}
}];
[[QCloudSMHService defaultSMHService]batchDelete:req];

Query task status Here you need to poll the task status until queried the task result.
QCloudGetTaskStatusRequest *req = [QCloudGetTaskStatusRequest new];
req.spaceId = @"spaceId";
req.spaceOrgId = @"spaceOrgId";
req.libraryId = @"libraryId";
req.userId = @"userId";
// Back taskId
req.taskIdList = @[taskId];
[req setFinishBlock:^(NSArray * _Nonnull result, NSError * _Nonnull error) {

}];
[[QCloudSMHService defaultSMHService] getTaskStatus:req];

Advanced Batch Deleting Sample Code

The API encapsulates batch deletion and polling task status. setFinishBlock returns the final task result directly with no need to manually query task status.
QCloudSMHDeleteObjectRequest *req = [QCloudSMHDeleteObjectRequest new];
req.spaceId = @"spaceId";
req.spaceOrgId = @"spaceOrgId";
req.libraryId = @"libraryId";
req.userId = @"userId";

QCloudSMHBatchDeleteInfo *info = [QCloudSMHBatchDeleteInfo new];
// file path
info.path = @"totalPath";
req.batchInfos = @[info];
[req setFinishBlock:^(QCloudSMHBatchResult *result, NSError *_Nullable error) {

}];
[[QCloudSMHService defaultSMHService] deleteObject:req];


Ajuda e Suporte

Esta página foi útil?

comentários