DownloadTask mc.downloadFile(Object object)

下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径 (本地路径)。

Object object 参数

属性 类型 默认值 必填 说明
url String 下载资源的 url
header Object HTTP 请求的 Header
timeout Number 超时时间,单位为毫秒
filePath String 指定文件下载后存储的路径 (本地路径)
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

Object.success(Object res) 回调函数

属性 类型 说明
tempFilePath String 临时文件路径 (本地路径)。没传入 filePath 指定文件存储路径时会返回,下载后的文件会存储到一个临时文件
filePath String 用户文件路径 (本地路径)。传入 filePath 时会返回,跟传入的 filePath 一致
statusCode Number 开发者服务器返回的 HTTP 状态码

返回值

类型 说明
DownloadTask 下载任务对象

|

示例代码:

mc.downloadFile({
  url: 'https://test.com',
  success: function(res){
    console.log(res.tempFilePath);
  }
});

results matching ""

    No results matching ""

    results matching ""

      No results matching ""