getFileInfo(Object)
发布于 6 年前 作者 ayi 13773 次浏览 来自 问答

这个函数不知道怎么死活没有反应

// wx.getFileInfo({

    //   filePath: filePath,

    //   success(res) {

    //     console.log('get: ’ + res.size)

    //     console.log(res.digest)

    //   },

    //   fail: function (res) {

    //     console.log(‘fail:’ + res)

    //   }

    // });

6 回复

工具上的话应该是已知问题,getFileInfo只会进入complete回调。你可以试一下。

你好,我是在pc开发工具iphone6测试:源码

 //保存文件api演示函数

  saveApi: function () {

    var that = this;

    wx.chooseImage({

      success: function (res) {

        var tempFilePaths = res.tempFilePaths

        that[‘chooseFile’] = tempFilePaths;

        console.log(‘tempFilePaths’ + tempFilePaths);

        wx.saveFile({

          tempFilePath: tempFilePaths[0],

          success: function (res) {

            var savedFilePath = res.savedFilePath

            console.log(‘savedFilePath’ + savedFilePath);

            t__hat[‘tempFilePath’] = savedFilePath;__

          }

        })

      }

    });

  },

  getFileApi: function () {

    var that = this;

    // var filePath = that[‘tempFilePath’] ;

    // wx.getFileInfo({

    //   filePath: filePath,

    //   success(res) {

    //     console.log('get: ’ + res.size)

    //     console.log(res.digest)

    //   },

    //   fail: function (res) {

    //     console.log(‘fail:’ + res)

    //   }

    // });

    wx.getSavedFileList({

      success: function (res) {

        console.log(res.fileList)

        that.setData({ images: res.fileList })

      }

    })

  }

文档提到:

本地文件、临时文件

这两个概念怎么理解?

你好,请提供一下出现问题的机型和微信版本。工具上目前有个bug,只会回调complete,建议再真机上试一下看看。

本地文件指用saveFile保存到本地对文件。其他接口调用返回的文件都属于临时文件

谢谢  原来真的是需要在手机上测试才可以

情况正如你说的,谢谢 !

回到顶部