下载压缩包文件,安卓端可以下载,苹果端不能下载,请问如何解决?
发布于 5 年前 作者 bgong 10960 次浏览 来自 官方Issues
下载 压缩包 文件,在安卓端下载,采用下面的代码当不是文档的时候,就会弹出下载文件的界面,但是在苹果端就不能出现,请问怎样才能出现下载文件
的界面,能够将下载的文件分享给朋友?

wx.cloud.downloadFile({
      fileID: fileId
    }).then(res => {
      console.log('下载成功', res)
      var filePath = res.tempFilePath              //返回的文件临时地址,用于后面打开本地预览所用
      var filename = filePath;
      var index1 = filename.lastIndexOf(".");
      var index2 = filename.length;
      var postf = filename.substring(index1, index2);//后缀名
      var postf1 = postf.replace(/\./g, '')
  wx.openDocument({
    filePath: res.tempFilePath,
    fileType: postf1 ,
    showMenu: true,
    success: function (res) {
      console.log('打开文档成功')
    },
    fail:   console.log('打开文档失败'),
  })
    }).catch(res => {
      console.log('下载失败', res)
    })
  } else {
    wx.showToast({
      icon: "none",
      title: '下载链接为空了',
    })
   }
}
回到顶部