May 20, 2021 WeChat Mini Program Development Document
Download files from cloud storage
Request parameters
Field | Description | The data type | The default | Required |
---|---|---|---|---|
fileID | Cloud file ID | String | - | Y |
Promise returns parameters
Field | Description | The data type |
---|---|---|
fileContent | The contents of the file | Buffer |
statusCode | The HTTP status code returned by the server | Number |
The argument was returned incorrectly
Field | Description | The data type |
---|---|---|
errCode | Error code | Number |
errMsg | Error message, format apiName:fail msg | String |
Promise style
const cloud = require('wx-server-sdk')
exports.main = async (event, context) => {
const fileID = 'xxxx'
const res = await cloud.downloadFile({
fileID: fileID,
})
const buffer = res.fileContent
return buffer.toString('utf8')
}