wx.cloud.downloadFile

wx.cloud.downloadFile

从云存储空间下载文件

请求参数

字段 说明 数据类型 默认值 必填
fileID 云文件 ID String - Y
config 配置 Object - N
success 成功回调
fail 失败回调
complete 结束回调

config 对象定义

字段 说明 数据类型
env 使用的环境 ID,填写后忽略 init 指定的环境 String

success 返回参数

字段 说明 数据类型
tempFilePath 临时文件路径 String
statusCode 服务器返回的 HTTP 状态码 Number
errMsg 成功为 downloadFile:ok,失败为失败原因 String

fail 返回参数

字段 说明 数据类型
errCode 错误码 Number
errMsg 错误信息,格式 downloadFile:fail msg String

使用示例

Callback 风格

wx.cloud.downloadFile({
  fileID: 'a7xzcb',
  success: res => {
    // get temp file path
    console.log(res.tempFilePath)
  },
  fail: err => {
    // handle error
  }
})

Promise 风格

wx.cloud.downloadFile({
  fileID: 'a7xzcb'
}).then(res => {
  // get temp file path
  console.log(res.tempFilePath)
}).catch(error => {
  // handle error
})

返回值 如果请求参数中带有 success/fail/complete 回调中的任一个,则会返回一个 downloadTask 对象,通过 downloadTask 对象可监听下载进度变化事件,以及取消下载任务。

posted on   AtlasLapetos  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【.NET】调用本地 Deepseek 模型
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 我与微信审核的“相爱相杀”看个人小程序副业
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示