Appearance
批量下载文件(可下载重定向地址)
方法名
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)
})参数说明
| 参数名 | 参数类型 | 是否必填 | 默认值 | 参数描述 |
|---|---|---|---|---|
| list | String[] | 是 | 无 | 下载地址列表 |
| saveDir | String | 否 | 无 | 保存的文件地址(绝对路径) |
回调
回调示例
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
}回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.url | String | 当前下载的地址 |
| data.type | String | 下载类型,start:开始下载,downloading:下载中,success:下载完成,error:下载出错 |
| data.percent | Float | 当前下载的进度(<=1) |
| data.size | Integer | 已下载的大小,单位:字节 |
| data.totalSize | Integer | 文件总大小,单位:字节 |
| data.path | String | 下载完成后的文件路径 |
| code | Integer | 返回类型,0.成功,其他:失败 |

