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

Downloading a File

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-12-31 11:48:17
By default, files in CloudBase cloud storage are publicly readable to all users.
Note:
You can also use cloud storage security rules to set looser or stricter read/write permissions for cloud storage.
Using the SDK, you can download files from the cloud storage space. Pass the globally unique fileID of the cloud storage file when calling.
Web
WeChat Mini Program
Node.js
//Step one: introduce the Web SDK.
import tcb from "@cloudbase/js-sdk";

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

/**
Step three: login authentication process. The code is omitted here. See:
https://www.tencentcloud.com/document/product/876/41728?from_cn_redirect=1
*/

app
.downloadFile({
fileID: "cloud://a/b/c"
})
.then((res) => {
console.log(res);
});

// 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
.downloadFile({
fileID: "cloud://a/b/c" // File ID
})
.then((res) => {
// Return a temporary file path.
console.log(res.tempFilePath);
});

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

const app = tcb.init({
env: "your-env-id"
});

app
.downloadFile({
fileID: "cloud://a/b/c"
})
.then((res) => {
// fileContent is of type Buffer.
console.log(res.fileContent);
});

Note:
If you need to download files from cloud storage directly in the browser or use cloud storage as an image host, see Obtaining Temporary Link.


ヘルプとサポート

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

フィードバック