tencent cloud

Smart Media Hosting

Obtaining File Link

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

Introduction

This document provides an API overview for file download URLs, document preview URLs, and thumbnail URLs, as well as SDK example code.
API
Operation Description
Get document preview URL
Get file download link
Get photo/video cover thumbnail link

Document Preview

Feature Overview

To obtain document preview URL.

Example Code

try {
val previewAccessUrl: String = smh.getPreviewAccessUrl(
//file path
filePath = "filePath",
//historical version number
historyId = 123456,
//purpose (for marking the usage scenario of the link)
purpose = Purpose.PREVIEW
)
} catch (e: Exception) {
e.printStackTrace()
}

Getting File Download Link

Feature Overview

To get file download link.

Example Code

try {
val downloadAccessUrl: String = smh.getDownloadAccessUrl(
//file path
filePath = "filePath",
//historical version number
historyId = 123456,
//whether the file path has been url-encoded
encode = true
)
} catch (e: Exception) {
e.printStackTrace()
}

Getting Thumbnail

Feature Overview

To obtain thumbnail link.

Example Code

Example 1:
try {
val thumbnailUrl: String = smh.getThumbnailAccessUrl(
//Filename
name = "name",
//Directory name
dir = Directory(),
//historical version number
historyId = 123456,
//generated preview image size
size = 100,
//proportional scaling percentage, this parameter is valid only when Size is not passed
scale = 80,
//scale width, this parameter is valid only when height is not passed and scaled proportionally, and when Size and Scale are not passed;
widthSize = 100,
//scale height, this parameter is valid only when width is not passed and scaled proportionally, and when Size and Scale are not passed;
heightSize = 100,
//purpose (for marking the usage scenario of the link)
purpose = Purpose.PREVIEW
)
} catch (e: Exception) {
e.printStackTrace()
}
Example 2:
try {
val thumbnailResult: ThumbnailResult = smh.getThumbnail(
//Filename
name = "name",
//Directory name
dir = Directory(),
//generated preview image size
size = 100,
//proportional scaling percentage, this parameter is valid only when Size is not passed
scale = 80,
//scale width, this parameter is valid only when height is not passed and scaled proportionally, and when Size and Scale are not passed;
widthSize = 100,
//scale height, this parameter is valid only when width is not passed and scaled proportionally, and when Size and Scale are not passed;
heightSize = 100,
//number of frames, frame processing targeting gif
frameNumber = 6,
//purpose (for marking the usage scenario of the link)
purpose = Purpose.PREVIEW
)
val thumbnailUrl = thumbnailResult.location
} catch (e: Exception) {
e.printStackTrace()
}


도움말 및 지원

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

피드백