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,
						});
					},
				});
相关推荐
布局呆星1 小时前
Vue Router :基础使用与嵌套路由实战
前端·javascript·vue.js
小码哥_常7 小时前
安卓开发秘籍:解锁10大性能优化秘诀
前端
try2find8 小时前
打印ascii码报错问题
java·linux·前端
郑州光合科技余经理8 小时前
同城O2O海外版二次开发实战:从支付网关到配送算法
开发语言·前端·后端·算法·架构·uni-app·php
冰暮流星9 小时前
javascript事件案例-全选框案例
服务器·前端·javascript
Csvn10 小时前
前端性能优化实战指南
前端
Moment10 小时前
2026 年,AI 全栈时代到了,前端简历别再只写前端技术了 🫠🫠🫠
前端·后端·面试
糯米团子74910 小时前
Web Worker
开发语言·前端·javascript
freewlt10 小时前
React Server Components 深度解析
前端·react.js·前端框架
wordbaby10 小时前
一次跨端 Loading 卡死复盘:把请求计数从 Axios 拦截器迁到 try/catch/finally
前端·axios