微信小程序接收后端二进制文件流并保存到本地

微信小程序保存到本地的话,我的理解是每个人每种型号的手机不一样,所以实现起来很繁琐,所以可以下载到临时文件区后转发好友!!!

临时文件存放区:wx.env.USER_DATA_PATH

// 下载资料
			downloadDrawingZip() {
				this.canDownload = true
				uni.showLoading({ title: '正在下载......' })
				let realFileName = orderId + '.zip'
				let fileSavePath = wx.env.USER_DATA_PATH + '/' + realFileName
				console.log('106', fileSavePath)
				wx.downloadFile({
					url: '#你的接口url',
					header: {
						'Content-Type': 'application/octet-stream'
					},
					filePath: fileSavePath,
					success: (res) => {
						console.log(111, res)
						uni.hideLoading()
						wx.shareFileMessage({
							filePath: res.filePath,
							fileName: realFileName,
							success(data) {
								uni.showToast({
									icon: 'success',
									mask: true,
									title: '转发成功!',
									duration: 2000,
									});
								},
							fail: console.error,
											
							})
						
						this.canDownload = false
					},
					fail: (err) => {
						console.error(err)
						uni.showToast({
							icon: 'error',
							title: '下载失败!',
							duration: 3000
						})
						this.canDownload = false
					}
				})
			}
  • 10
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值