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

Copying File

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-01-07 14:15:08

Description

Used for copying files.
Note:
Required permissions: admin, space_admin, or copy_file/copy_file_force. For details about permissions, see Generate Access Token API.
This interface requires both source and target to specify the complete file path. Source and target can span directories to achieve the feature of copying 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 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. Please refer to create tenant space
String
No
FilePath
complete file path, such as foo/bar2/file.docx
String
No
ConflictResolutionStrategy
Handling method when filename conflict, default is rename
ask: Returns HTTP 409 Conflict and SameNameDirectoryOrFileExists error code when conflicts with
rename: Automatically rename files when 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
String
Yes
UserId
User identity recognition. When the permission corresponding to the access token is admin permission and the user identity recognition during the access 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 copied.
Request body example:
{
"copyFrom": "foo/bar/file_old.docx"
}
Request body field description:
Request parameters
Description
Type
Required or Not
copyFrom
the source file path to be copied, see View File Details
String
Yes

Response

Response code

Copied 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 specified target path during replication.
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.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan