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

Obtaining File Link

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 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()
}


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan