tencent cloud

Downloading a File

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 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.


도움말 및 지원

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

피드백