tencent cloud

Smart Media Hosting

Batch Move Files

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

Introduction

This document provides an API overview for batch rename, move directory, or file as well as SDK example code.
API
Operation Description
Batch rename or move directories or files

SDK API Reference

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

Batch Renaming or Moving a Directory or File

Feature Description

Batch rename or move directories or files
When moving multiple projects asynchronously, return HTTP 202 Accepted.
When moving fewer projects synchronously, return HTTP 200 OK (all execution successful) or HTTP 207 Multi-Status (part or all execution failed).

Batch Move Instance Code

Start Batch Move

QCloudSMHBatchMoveRequest *req = [QCloudSMHBatchMoveRequest new];
req.spaceId = @"spaceId";
req.libraryId = @"libraryId";
QCloudSMHBatchMoveInfo *info = [QCloudSMHBatchMoveInfo new];
// original path
info.from = @"from";
// target path
info.to = @"target";
// whether move permission
info.moveAuthority = YES;
// Filename conflicts with target path resolution policy
info.conflictStrategy = QCloudSMHConflictStrategyEnumRename;
req.batchInfos = @[info];
[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
result.taskId;
}

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


Query Task Status

Poll the task status here until the task result is queried.
QCloudGetTaskStatusRequest *req = [QCloudGetTaskStatusRequest new];
req.spaceId = @"spaceId";
req.libraryId = @"libraryId";
// taskId returned from the previous step
req.taskIdList = @[taskId];
[req setFinishBlock:^(NSArray * _Nonnull result, NSError * _Nonnull error) {

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

Advanced Batch Move Example Code

This API encapsulates batch move and polling task status. setFinishBlock returns the final task result directly with no need to manually query task status.
QCloudSMHMoveObjectRequest *req = [QCloudSMHMoveObjectRequest new];
req.spaceId = @"spaceId";
req.libraryId = @"libraryId";
QCloudSMHBatchMoveInfo *info = [QCloudSMHBatchMoveInfo new];
// original path
info.from = @"from";
// target path
info.to = @"target";
// whether move permission
info.moveAuthority = YES;
// Filename conflicts with target path resolution policy
info.conflictStrategy = QCloudSMHConflictStrategyEnumRename;

req.batchInfos = @[info];
[req setFinishBlock:^(QCloudSMHBatchResult *result, NSError *_Nullable error) {

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


Ajuda e Suporte

Esta página foi útil?

comentários