接口返回的pdf链接,在小程序里面如何保存到手机?
发布于 5 年前 作者 yan39 12738 次浏览 来自 问答

接口返回的合同pdf文件,小程序里面通过,wx.downloadFile,然后再wx.openDocument打开,但是我想保存文件到手机如何做?如何找到保存的文件并打印?

  wx.downloadFile({ //下载//服务器上的pdf地址

     url: “https://wlbservicet.zgw.com/Agreement/Transport/Pdf/2019/12/12/货物运输合同-TN201912120007.pdf”,

     // filePath: wx.env.USER_DATA_PATH + ‘/test.pdf’, //自定义文件地址

     success: function(res) {

       console.log(res)

       wx.hideLoading();

       wx.showLoading({

         title: ‘打开中。。。’,

       })

       var filePath = res.tempFilePath

       wx.openDocument({ //打开

         filePath: res.tempFilePath,

         success: function(resp) {

           console.log(resp)

           wx.hideLoading();

         }

       })

     }

   })

3 回复

老哥解决了吗?现在也遇到了这样的问题,好难受啊!

回到顶部