uniapp小程序文件下载保存

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,
						});
					},
				});

你可能感兴趣的:(uni-app,小程序,前端)