tencent cloud

Smart Media Hosting

Batch Processing

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

Introduction

This document provides API introduction about batch processing and example code.

Deleting Directories or Files in Batches

Feature Description

Delete directories or files in batches.

Sample Code

try {
let items :SMHBatchDeleteObject[] = [
{path:`test/key1`,permanent:false},
{path:`test/key2`,permanent:false}
]
let result = await SMHBatchApis.batchDeleteFile({
libraryId: "libraryId",
spaceId: "spaceId",
items: items
});
} catch (e) {
// Exception handling
}

Parameter Description

Request parameters.
Description
Type
Required or Not
libraryId
Media Library ID, obtain it after creating a media library in the media hosting console, see Create Media Library
String
Yes
spaceId
Space ID. If the media library is in single-tenant mode, this parameter is fixed as hyphen (`-`); if the media library is in multi-tenant mode, you must specify this parameter. See Create Tenant Space
String
No
items
Set of batch operations
SMHBatchDeleteObject array
Yes
path
Deleted directory, album, or file path
String
Yes
permanent
When the recycle bin is enabled, this parameter specifies whether to move files to the recycle bin or permanently delete them. true: permanently delete, false: move to recycle bin, default to false.
Bool
Yes

Batch Copying Directories or Files

Feature Description

Batch copy directories or files.

Sample Code

try {
let items :SMHBatchCopyObject[] = [
{copyFrom:`test/key1`,to:`test/key1_copy`},
{copyFrom:`test/key2`,to:`test/key2_copy`},
]
let result = await SMHBatchApis.batchCopyFile({
libraryId: "libraryId",
spaceId: "spaceId",
items: items
});
} catch (e) {
// Exception handling
}

Parameter Description

Request parameters.
Description
Type
Required or Not
libraryId
Media Library ID, obtain it after creating a media library in the media hosting console, see Create Media Library
String
Yes
spaceId
Space ID. If the media library is in single-tenant mode, this parameter is fixed as hyphen (`-`); if the media library is in multi-tenant mode, you must specify this parameter. See Create Tenant Space
String
No
items
Set of batch operations
SMHBatchCopyObject array
Yes
to
Target directory, album, or file path, such as foo/bar/file_new.docx
String
Yes
copyFrom
Source directory, album, or file path to be copied
String
Yes
copyFromSpaceId
Specify the space where the source directory or file is located when copying across spaces. Do not specify this field when copying within the same space.
String
No
conflictResolutionStrategy
Handling method for filename conflict: if the target is a directory or album, it defaults to ask and does not support overwrite; if the target is a file, it defaults to rename.
conflicts with return
status: 409 and SameNameDirectoryOrFileExists error code
rename file automatically when conflicts with
overwrite: return status 409 and SameNameDirectoryOrFileExists error code if the target is a directory when conflict occurs, otherwise overwrite the existing file
SMHConflictResolutionStrategy
No

Batch Renaming or Moving Directories/Files

Feature Description

Batch rename or move directories/files.

Sample Code

try {
let items :SMHBatchMoveObject[] = [
{from:`test/key1`,to:`test/key1_move`},
{from:`test/key2`,to:`test/key2_move`},
]
let result = await SMHBatchApis.batchMoveFile({
libraryId: "libraryId",
spaceId: "spaceId",
items: items
});
} catch (e) {
// Exception handling
}

Parameter Description

Request parameters.
Description
Type
Required or Not
libraryId
Media Library ID, obtain it after creating a media library in the media hosting console, see Create Media Library
String
Yes
spaceId
Space ID. If the media library is in single-tenant mode, this parameter is fixed as hyphen (`-`); if the media library is in multi-tenant mode, you must specify this parameter. See Create Tenant Space
String
No
items
Set of batch operations
SMHBatchMoveObject array
Yes
to
Target directory, album, or file path, such as foo/bar/file_new.docx
String
Yes
from
Source directory, album, or file path to be renamed or moved
String
Yes
copyFromSpaceId
Specify the space where the source directory or file is located when moving across spaces. Do not specify this field when moving within the same space.
String
No
conflictResolutionStrategy
Handling method for filename conflict: if the target is a directory or album, it defaults to ask and does not support overwrite; if the target is a file, it defaults to rename.
ask: return when conflicts with
status: 409 and SameNameDirectoryOrFileExists error code
rename file automatically when conflicts with
overwrite: return status 409 and SameNameDirectoryOrFileExists error code if the target is a directory when conflict occurs, otherwise overwrite the existing file
SMHConflictResolutionStrategy
No

Ajuda e Suporte

Esta página foi útil?

comentários