wx.downloadFile 用servlet方式下载无法打开文件

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

    wx.downloadFile({

      url: 'http://localhost:8080/api/home/downloadFile?filePath='+this.data.filePath,   //这种方式无法打开文件,用浏览器直接访问可以下载文件

      // url: ‘http://localhost/web/test.pdf’,   //这种方式能正常打开文件

      success: function (res) {

        var filePath = res.tempFilePath

        wx.openDocument({

          filePath: filePath,

          success: function (res) {

            console.log(‘打开文档成功’)

          }

        })

      }

    })

无法打开文件的返回信息:

errMsg: “downloadFile:ok”

statusCode: 200

tempFilePath: “wxfile://tmp_1139539211o6zAJs9zeOecJoD5XWDrNvK-iE6U42217618b76e06251e6efc5265c234ed”

1 回复
jxu
jxu1 楼6 年前

你加个后缀名看看