后浪云百度小程序教程:cloud.downloadFile

  • cloud.downloadFile

    cloud.downloadFile

    下载云存储文件

    参数

    名称类型必须说明
    optionObject
    option.fileIDString文件 ID

    返回值 Promise

    resolve 参数:

    名称类型说明
    requestIDString请求 ID
    fileContentbuffer文件内容

    reject 参数:

    名称类型说明
    codeString错误码
    messageString错误信息

    代码示例

     
     
     
    1. const cloud = require('swan-server-sdk')
    2. exports.main = async (event, context) => {
    3. cloud.init(context)
    4. const res = await cloud.downloadFile({
    5. fileID: 'file-id-01',
    6. })
    7. return res.fileContent
    8. }
    THE END