tencent cloud

Smart Media Hosting

Product Introduction
Product Overview
Feature Description
Product Strengths
Use Cases
Basic Concept
Purchase Guide
Quick Start
Create Media Library
Initiate request
Service Level API Document
History
Introduction
API Category
Making API Requests
PaaS Service APIs
Official Cloud Disk APIs
Data Types
Error Codes
Business Level API Document
Introduction
Access Token Operation API
Tenant Space Operation API
File Operation API
Directory or Album Operation API
Recycle Bin Operation API
Quota Operation API
Query Task Operation API
Search Operation API
Historical Version Operations API
Directory and File Batch Operation API
Collection Operation API
Error Codes
SDK Documentation
Android SDK
iOS SDK
HarmonyOS SDK
FAQs
Enterprise Network Disk
Product Introduction
Purchase Guide
Quick Start
FAQs
Service Level Agreement
Glossary

Batch Copy File

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-01-07 10:49:06

Introduction

This document provides an API overview and SDK sample code for batch file copy.
API
Operation Description
Batch Copy Files

SDK API Reference

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

Batch Copying Files

Feature Description

Used for batch copying directories or files. Cross-space copying is not supported.
When projects are copied asynchronously in large numbers, return HTTP 202 Accepted.
When projects are copied synchronously in small numbers, return HTTP 200 OK (all execution successful) or HTTP 207 Multi-Status (part or all execution failed).

Batch Copying File Code

Starting Batch Replication

QCloudSMHBatchCopyRequest *req = [QCloudSMHBatchCopyRequest new];
req.spaceId = @"spaceId";
req.libraryId = @"libraryId";
// parameter is required to implement the save network disk feature
req.shareAccessToken = @"shareAccessToken";
QCloudSMHBatchCopyInfo *info = [QCloudSMHBatchCopyInfo new];
// original path
info.from = @"from";
// target path
info.to = @"target";
// The fromLibraryId and fromSpaceId parameters are used to implement the save network disk feature and must be used with shareAccessToken.
info.fromLibraryId = @"fromLibraryId";
info.fromSpaceId = @"fromSpaceId";
// whether move permission
info.moveAuthority = YES;
// Resolve when file name conflicts with target path
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]batchCopy: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 Replication Example Code

This API encapsulates batch copy and polling task status. The setFinishBlock returns the final task result directly, with no need to manually query task status.
QCloudSMHCopyObjectRequest *req = [QCloudSMHCopyObjectRequest new];
req.libraryId = @"libraryId";
req.spaceId = @"spaceId";
// shareAccessToken is required to save the network disk
req.shareAccessToken = @"shareAccessToken";

QCloudSMHBatchCopyInfo *info = [QCloudSMHBatchCopyInfo new];
// source path
info.from = @"fromPath";
// target path
info.to = @"toPath";
info.conflictStrategy = QCloudSMHConflictStrategyEnumRename;
// shareAccessToken fromSpaceId fromLibraryId are required to save the network disk
if (shareAccessToken) {
info.fromSpaceId = @"fromSpaceId";
info.fromLibraryId = @"fromLibraryId";
}
req.batchInfos = @[info];
[req setFinishBlock:^(QCloudSMHBatchResult *result, NSError *_Nullable error) {

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


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백