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

Renaming or Moving Files

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-01-07 14:15:08

Description

Rename or move files.
Note:
Required permissions: admin, space_admin, or move_file/move_file_force. For details on permissions, see Generate Access Token interface.
This API requires both source and target to specify the complete file path. Source and target can span directories to achieve the feature of moving files to any other directory, and supports renaming files simultaneously.
It does not automatically create the intermediate parent directories required, so you must ensure that all levels of directories in the path exist.

Request

Request Example

PUT /api/v1/file/{LibraryId}/{SpaceId}/{FilePath}?conflict_resolution_strategy={ConflictResolutionStrategy}&access_token={AccessToken}&user_id={UserId}

Request Parameter

Request parameter
Description
Type
Required or Not
LibraryId
Media Library ID, obtained 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 a hyphen (`-`). If the media library is in multi-tenant mode, you must specify this parameter. See Create Tenant Space.
String
No
FilePath
complete file path, such as foo/bar2/file.docx
String
No
ConflictResolutionStrategy
Handling method when filename conflict occurs, default is rename
ask: Returns HTTP 409 Conflict and SameNameDirectoryOrFileExists error code when conflicts with
rename: Automatically rename the file if conflicts with
overwrite:
If the target is a directory or album, it defaults to ask and does not support overwrite
If the target is a file, overwrite the existing file
When a file with an earlier version exists in the target space, moving to overwrite is not supported.
String
No
AccessToken
Access token, see Generate Access Token for retrieval.
String
Yes
UserId
User identity recognition. When the access token corresponds to admin permission and the user identity recognition during token application is empty, it is used to temporarily designate user identity. For details, see Generate Access Token API
String
No

Request Body

application/json, specify the source file path to be renamed or moved.
Request body example:
{
"from": "foo/bar/file_old.docx"
}
Request body field description:
Request parameters
Description
Type
Required or Not
from
the source file path to be renamed or moved. For retrieval, see View File Details
String
Yes

Response

Response code

Rename or move successfully, return HTTP 200 OK.

Response Body

application/json
Response body example:
{ "path": [ "foo", "bar", "file_new (1).docx" ] }
Response body field description:
Request parameters.
Description
Type
path
String array or null
If it is an array of strings, it indicates the final file path. The last element in the array represents the final file name, and the other elements represent each first-level directory name. Since existing files with the same name may be renamed automatically, the final path here may not equal the target path specified during movement or renaming.
If it is null, it means that a parent directory of the target path has been deleted, and the target file can no longer be accessed.
String

Error Codes

This request operation has no special error messages. For common error messages, see Error Codes.

도움말 및 지원

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

피드백