Skip to content

批量下载文件(可下载重定向地址)

方法名

batchDownload

用法

用法示例

js
module.batchDownload({
  list: [
    "http://mhcg.392.me/adiuc.php?d=59930",
    "http://www.yeyuboke.com/svga/1.svga"
  ],
  saveDir: "/storage/emulated/0/leven_file/"
}, res => {
  console.log(res)
})

参数说明

参数名参数类型是否必填默认值参数描述
listString[]下载地址列表
saveDirString保存的文件地址(绝对路径)

回调

回调示例

json
{
    "data": {
        "url": "http://mhcg.392.me/adiuc.php?d=59930",
        "type": "start"
    },
    "message": "开始下载",
    "code": 0
}

{
    "data": {
        "percent": 0.00029610403430180174,
        "type": "downloading",
        "url": "http://mhcg.392.me/adiuc.php?d=59930",
        "size": 1024,
        "totalSize": 3458244
    },
    "message": "下载中",
    "code": 0
}

{
    "data": {
        "url": "http://www.yeyuboke.com/svga/1.svga",
        "type": "success",
        "path": "/storage/emulated/0/leven_file/1.svga"
    },
    "message": "下载完成",
    "code": 0
}

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.urlString当前下载的地址
data.typeString下载类型,start:开始下载,downloading:下载中,success:下载完成,error:下载出错
data.percentFloat当前下载的进度(<=1)
data.sizeInteger已下载的大小,单位:字节
data.totalSizeInteger文件总大小,单位:字节
data.pathString下载完成后的文件路径
codeInteger返回类型,0.成功,其他:失败