收藏
回答

IOS wx.downloadFile 下载视频 报错 的问题 ?

在安卓机上下载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.pushlist.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,

                                })

                              }

                            },

                          })

                        }

                      })

                    }

                  }

                })

              }

            })

        }

      }

    })


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容