目前小程序要做保存excel、pdf等文件的功能, 我调用了wx.downFile,然后再调用saveFile,直接是走进了saveFile的success函数,但是保存的文件去哪里打开呢,还是说这个保存并不是保存到手机上? 还是说,现在的小程序并不支持保存文件到手机上(不是临时保存,是可以在退出小程序后再次在手机中找到并且打开) wx.downloadFile({
url: item.url,
// filePath: wx.env.USER_DATA_PATH + '/' + item.fullName,
success (res) {
if (res.statusCode === 200) {
wx.hideLoading()
// let tempFilePath = res.filePath // 如果设置了filePath参数,则不会有tempFilePath
let tempFilePath = res.tempFilePath
wx.saveFile({
tempFilePath,
success (res) {
// 可以进行到这里
console.log(res);
const savedFilePath = res.savedFilePath
wx.showToast({
title: '下载成功',
icon: 'none',
mask: true
})
},
fail (err) {
console.log(err);
wx.showToast({
title: '下载失败,请重新尝试',
icon: 'none',
mask: true
})
}
})
}
}
})
|