收藏
回答

wx.saveFile保存文件失败是什么情况

问题模块
API和组件
startRecord: function () {
    var that = this;
    // wx.showToast({
    //   title: '已开始录音',
    //   icon: 'success',
    //   duration: 2000
    // })
    wx.startRecord({
      success: function (res) {
        tempFilePath = res.tempFilePath;
        wx.saveFile({
          tempFilePath: tempFilePath,
          success: function (res) {
            // success
            savedFilePath = res.savedFilePath;
            var info_v = new Info();
            info_v.path = savedFilePath;
            info_v.mode = "voice";
            info_v.time = util.formatTime(new Date());
            // info_v.getSize();
            wx.getSavedFileInfo({
              filePath: savedFilePath,
              success: function (res) {
                // success
                info_v.size = (res.size / 1024).toFixed(2) + "Kb";
                console.log(info_v);
                infos.push(info_v);
                that.setData({
                  arr_info: infos,
                })
                console.log(infos);
              },
              fail: function () {
                // fail
              },
            })
            // info_v.size = getSize.getS(savedFilePath);
          },
          fail: function () {
            // fail
            console.log("fail")
          },
        })
      },
      fail: function (res) {
        //录音失败
      }
    })
  },
  stopRecord: function () {
    // wx.hideToast();
    wx.stopRecord();
  },

在模拟器上可以正常保存,在ios手机则输出命令行:fail,之前保存图片也有类似问题,换临时路径规避了,可这个就郁闷了

最后一次编辑于  2017-02-20  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏关注问题回答