比如下载下面URL的图片,下载到手机里的文件变成了“fileDownload”,并且没有后缀名
getDownload() {
const downloadTask = uni.downloadFile({
url: 'http://10.4.120.78:8802/service/sys/fileDownload?localPath=cmecFiles/merge&fileName=8bc46b3880fb5a1c6eb9bf61a71c646e-icon-52.png',
success: (res) => {
if (res.statusCode === 200) {
console.log('下载成功',res);
}
let that = this;
uni.saveFile({
tempFilePath: res.tempFilePath,
success: function(red) {
that.luj = red.savedFilePath
console.log(red,'保存成功')
uni.showToast({
icon: 'none',
mask: true,
title: '文件已保存:' + red.savedFilePath, //保存路径
duration: 3000,
});
setTimeout(() => {
//打开文档查看
uni.openDocument({
filePath: red.savedFilePath,
success: function(res1) {
console.log(res1,'打开文档成功');
}
});
}, 3000)
}
});
}
});
downloadTask.onProgressUpdate((res) => {
console.log('下载进度' + res.progress);
console.log('已经下载的数据长度' + res.totalBytesWritten);
console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
});
},
1 个回复
4***@qq.com - block
解决了吗