tencent cloud

CloudBase

Product Introduction
Product Overview
Features and Strengths
Use Cases
System Limits
Purchase Guide
Product Pricing
Description Of Billing Capability Items
Yearly/Monthly Subscription Package Description
Alarm and Notification
Overdue Payment Instructions
Development Guide
Cloud Storage
Database
Identity Verification
Cloud function
Static website management
SDK Documentation
Client SDK
Server SDKs
Management-side SDK
Product Agreement
Cloud Development Service Level Agreement

Obtaining a Temporary Link

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-12-31 11:48:16
You can use fileID to obtain an HTTPS link for a specified file in the cloud storage space. (Cloud storage provides a free CDN domain name.)
Note:
The HTTPS link obtained for a file with public read permissions does not expire. For example, if the default permission is set to public read, the obtained link is valid permanently.
The HTTPS link obtained for a file with private read permissions is temporary. For example, you can combine user identity authentication and the security rule to set the permission of the file to be readable only by the uploader, creator, or administrator of the file. In this case, only users who have passed CloudBase (TCB) authentication have the permission to obtain a temporary link.
The validity period can be dynamically set. Requests for temporary links after the validity period will be rejected to ensure file security.
Up to 50 temporary links can be obtained at a time; batch processing is required if the number exceeds 50.
CDN enables Gzip compression by default for resources with suffixes such as .js, .html, .css, .xml, .json, .shtml, and .htm, and with sizes ranging from 256 bytes to 2 MB.
By using the SDK to call the getTempFileURL to specify fileID of the file, you can obtain an HTTPS link for the specified file in the cloud storage space.
Web
WeChat Mini Program
Node.js
//Step 1: Introduce the Web SDK.
import tcb from "@cloudbase/js-sdk";

//Step 2: Perform initialization.
const app = tcb.init({
env: "your-env-id"
});

//Step 3: Authenticate login. The following code is not complete. You need to select a login method. For details, see Quick Start > Login and User Cases.
const auth = app.auth({
persistence: "local" //The login authentication remains valid for 30 days until the user logs out or changes the password.
});

app
.getTempFileURL({
fileList: ["cloud://a/b/c", "cloud://d/e/f"]
})
.then((res) => {
// fileList is an object array with the following structure.
// [{
// fileID: 'cloud://webtestjimmy-5328c3.7765-webtestjimmy-5328c3-1251059088/Tencent Cloud.png', // File ID.
// tempFileURL: '', // Temporary file network connection.
// maxAge: 120 * 60 * 1000, // Validity period.
// }]
console.log(res.fileList);
});

//First, use wx.cloud.init for initialization. There is no need to import the SDK again on the mini program side, and authentication is not required.
wx.cloud
.getTempFileURL({
fileList: ["cloud://a/b/c", "cloud://d/e/f"]
})
.then((res) => {
// fileList is an object array with the following structure.
// [{
// fileID: 'cloud://webtestjimmy-5328c3.7765-webtestjimmy-5328c3-1251059088/Tencent Cloud.png', // File ID.
// tempFileURL: '', // Temporary file network connection.
// maxAge: 120 * 60 * 1000, // Validity period.
// }]
console.log(res.fileList);
});

const tcb = require("@cloudbase/node-sdk");
const app = tcb.init();

app
.getTempFileURL({
fileList: ["cloud://a/b/c", "cloud://d/e/f"]
})
.then((res) => {
// fileList is an object array with the following structure.
// [{
// fileID: 'cloud://webtestjimmy-5328c3.7765-webtestjimmy-5328c3-1251059088/Tencent Cloud.png', // File ID.
// tempFileURL: '', // Temporary file network connection.
// maxAge: 120 * 60 * 1000, // Validity period.
// }]
console.log(res.fileList);
});



ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック