调用图片downloadFile下载成功但是临时路径为空?

发布于 8 年前作者 ping514372 次浏览最后编辑 8 年前来自 issues

在模拟器上是可以实现的。但是在iphoneX上。statusCode:200 .TempFilePath:wxfile://      就没有然后了。

wx.downloadFile({
      url: 'https://www.parrotfamily.cn/static/image/2019/鉴定卡.jpg',
      success(res) {
        that.showToast(JSON.stringify(res),300000);
        console.log('res:' + JSON.stringify(res));
        if (res.statusCode === 200) {
          //缓存图片
          const fs = wx.getFileSystemManager()
          fs.saveFile({
            tempFilePath: res.tempFilePath, // 传入一个临时文件路径
            success(res) {
              that.showToast('保存成功',JSON.stringify(res), 30000);
              that.setData({
                bgImage: res.savedFilePath,
                downImageState:true,
              })
              wx.setStorageSync('image_cache', res.savedFilePath)
            },
            fail(res){
              that.showToast('保存失败', JSON.stringify(res), 30000);
            }
          })
        }
      },
      fail(res){
        this.showToast('下载图片失败',2000);
        that.setData({
          downImageState: false,
        })
      }
    });
2 回复
omao
omao1 楼6 年前
xiama
xiama2 楼6 年前

麻烦提供能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html