微信小程序
云函数
# downloadFile
从云存储空间下载文件
请求参数
Promise 返回参数
错误返回参数
# 使用示例
Promise 风格
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
const fileID = 'xxxx'
const res = await cloud.downloadFile({
fileID: fileID,
})
const buffer = res.fileContent
return buffer.toString('utf8')
}