tencent cloud

Smart Media Hosting

Renaming a file

PDF
Focus Mode
Font Size
Last updated: 2026-01-07 11:03:08

Introduction

This document provides an API overview about file renaming as well as SDK example code.
API
Operation Description
Rename or move files

Renaming or Moving Files

Feature Overview

For renaming or moving files.

Example Code

//source filename
val sourceName = "sourceName"
//source folder
val sourceDir = Directory()
//target file name
val targetName = "targetName"
//target folder
val targetDir = Directory()

try {
val renameFileResponse: RenameFileResponse = smh.renameFile(
targetName = targetName,
targetDir = targetDir,
sourceName = sourceName,
sourceDir = sourceDir,
//Conflict strategy for filename conflicts
conflictStrategy = ConflictStrategy.RENAME
)
} catch (e: Exception) {
e.printStackTrace()
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback