uniapp小程序文件下载保存

javascript 复制代码
uni.downloadFile({
					url: that.baseUrl + '/app-api/erp/income/certificate/apply' + '?' +
						`type=${that.proveInfo.code}`,
					header: {
						'Authorization': 'Bearer test01'
					},
					success(res) {
						console.log(res);
						const tempFilePath = res.tempFilePath;
						let fileManager = uni.getFileSystemManager();
						fileManager.saveFile({
							tempFilePath: tempFilePath,
							filePath: `${uni.env.USER_DATA_PATH}/file/${that.proveInfo.desc}.pdf`,
							success: (result) => {
								console.log(result);
								uni.showToast({
									content: '文件保存成功,路径:' + result.savedFilePath,
								});
							},
							fail: (err) => {
								console.log(err)
							}
						})
					},
					fail(res) {
						console.log(res);
						uni.alert({
							content: res.errorMessage || res.error,
						});
					},
				});
相关推荐
西柚小萌新2 小时前
【论文写作】--LaTeX详细入门教程2
前端·html
qdkfz2 小时前
JavaScript 如何解析 Outlook .msg 文件 —— @kenjiuno/msgreader
前端·javascript
LuckyDog阿祥3 小时前
卸载Microsoft Edge:EdgeRemover完整操作指南
前端·edge
zhangxingchao3 小时前
AI应用开发九:从 Hermes Agent 学长期记忆
前端·人工智能·后端
xiaofeichaichai3 小时前
Vite原理与Webpack对比
前端·webpack·node.js
_杨瀚博3 小时前
小程序拍证件并局部裁剪
前端
handsome09164 小时前
windows开发uniapp如何上架app到app store
uni-app·上架
William_Xu4 小时前
React 新旧生命周期对比
前端