
uniapp开发微信小程序通过文件流下载文件
uniapp开发微信小程序下载文件
·
uni.downloadFile({
url: 'xx 请求地址,
header: {
'token': token //token 获取
},
success: (res) => {
if (res.statusCode === 200) {
var filePath = res.tempFilePath;
uni.saveFile({
tempFilePath: filePath,
success: function(saveRes) {
const savedFilePath = saveRes.savedFilePath
// 下载成功后,你可以进行一些处理,比如保存文件路径或打开文件等
uni.openDocument({
filePath: savedFilePath,
success: function() {
console.log('打开文档成功')
}
})
},
fail: function(failRes) {
console.log('保存文件失败:', failRes.errMsg);
}
});
}
}
});
更多推荐
所有评论(0)