在安卓机上下载30个视频毫无压力 ,但是同样的代码在IOS 手机一直报 errMsg: "downloadFile:fail'savefile: fail the maximum size of the file storage limit is exceeded"
// 下载素材
handleDownload() {
let _this = this;
_this.getSetting(function (e) {
if (e) {
if (_this.data.disabled) {
_this.setData({
disabled: false
})
}
let list = _this.data.list;
let listVide = [];
let file_ids=[];
for (let index = 0; index < list.data.length; index++) {
if (list.data[index].checked) {
listVide.push(list.data[index].video)
file_ids.push( list.data[index].file_id)
}
}
if (listVide.length<=0) {
wx.showModal({
title: '提示',
content: '请选择视频~',
showCancel: false,
})
_this.setData({
disabled: true
})
return false
}
wx.showLoading({
title: '下载中',
})
let videos=function(){
for (let a = 0; a < list.data.length; a++) {
list.data[a].checked=false;
}
_this.setData({
list
});
_this.saveVideo(file_ids);
}
let indexVide = 0;
for (let i = 0; i < listVide.length; i++) {
let fileName = new Date().valueOf();
wx.downloadFile({
url: listVide[i],
filePath: wx.env.USER_DATA_PATH + '/' + fileName + i + '.mp4',
success: res => {
let filePath = res.filePath;
wx.saveVideoToPhotosAlbum({
filePath,
success: file => {
indexVide++;
let fileMgr = wx.getFileSystemManager();
fileMgr.unlink({
filePath: wx.env.USER_DATA_PATH + '/' + fileName + i + '.mp4',
success: function (r) {
},
})
if (indexVide > listVide.length-1) {
wx.hideLoading()
wx.showToast({
title: '视频下载完成',
icon: 'success',
duration: 2000,
success(){
videos()
_this.setData({
disabled:true
})
}
})
}
},
fail: err => {
wx.hideLoading()
if (err.errMsg === 'saveVideoToPhotosAlbum:fail auth deny') {
wx.showModal({
title: '提示',
content: '需要您授权保存相册',
showCancel: false,
success: data => {
wx.openSetting({
success(settingdata) {
if (settingdata.authSetting['scope.writePhotosAlbum']) {
wx.showModal({
title: '提示',
content: '获取权限成功,再次点击下载即可保存',
showCancel: false,
})
} else {
wx.showModal({
title: '提示',
content: '获取权限失败,将无法保存到相册哦~',
showCancel: false,
})
}
},
})
}
})
}
}
})
}
})
}
}
})
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)