# getDownloadFileInfo ^8.11
获取文件的下载信息,包括下载进度和状态。一般在页面初始化时调用。如在当前页面下载了 20%,退出页面,再次进入时只是显示当前下载进度时可以调用该方法
# 请求参数
Prop | Type | Required | Default | Comment |
---|---|---|---|---|
downloadFolder | String | N | downFiles | 自定义下载目录,默认目录为 WeexApp/downFiles. downloadPath 为相对路径时,如为某个 sn8 对应的目录是 WeexApp/sn8。 支持绝对路径 |
urls | Array | Y | N/A | 需要下载的文件的url数组,支持分片下载。如果数组长度大于1,则下载完成后会合并为一个文件 |
fileSuffix | String | N | N/A | 保存的文件后缀. 如果urls的长度大于1则是必要的,否则非必要。 ios可不传 |
# 接口调用示例
const params = {
downloadFolder: "downFiles",
urls: [
"http://dolphin-weex-dev.msmartlife.cn/hybrid/docs/assets/img/1.1f83f6a2.png",
],
fileSuffix: "png",
};
this.$bridge
.getDownloadFileInfo(params)
.then((res) => {
console.log("getDownloadFileInfo-res", res);
})
.catch((err) => {
console.log("getDownloadFileInfo-err", err);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 返回参数
- 成功时返回
Prop | Type | Required | Comment |
---|---|---|---|
code | Number | Y | 返回码 0-获取下载信息成功; 其它:-1000-查询失败,-1001-(缺少参数 urls, 参数 urls 不能为空),-4009-存储未授权 |
msg | String | N | 返回信息 |
status | Number | Y | 当前下载状态。0-等待中, 1-下载中,2-下载成功,3-下载失败 |
fileSize | Number | Y | 文件大小,单位是字节 |
progress | Number | Y | 当前下载状态进度(0-100) |
# 返回示例
// 成功返回
{
code: 0,
fileSize: 73903,
msg: 'success',
progress: 100,
status: 2
}
// 失败返回
{
code: -1001,
msg: "参数urls不能为空"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14