Download and save uniapp pictures to Android error reporting app

To save a picture to a mobile photo album, you must download a download file to download the picture. The picture can be saved normally on IOS mobile phone, but it fails to save on an Android mobile phone

the returned address is of unknown type. At this time, saving will fail

Therefore, it is necessary to uni.download file ({filePath: wx.env.USER_ DATA_ PATH + ‘/ file.jpg ’})
add this code to change the address, and then it will be saved successfully

//Save images locally
			savePoster(){
				uni.showLoading({
					title:'Downloading...'
				})
				uni.downloadFile({
					url:this.playBillUrl,//  This is the web image address that the backend gets
					filePath: wx.env.USER_DATA_PATH + '/file.jpg',// This must be written here otherwise Android will download the address after it appears.unknown
					success:res => {
						uni.hideLoading()
						if (res.statusCode === 200) {
						
							uni.saveImageToPhotosAlbum({
								filePath: res.filePath,
								success: function() {
									uni.showToast({
										title:'save sucessfully'
									})
								},
								fail: function(res) {
									console.log(res)
									uni.showToast({
										title:'save failed, please try again later'
									})
								}
							});
						} else {
							uni.showToast({
								title:'Download error'
							})
							uni.hideLoading()	
						}
					
					}
				})

Read More: