收藏
回答

pc端微信进入小程序wx.downloadFile错误,求解决

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.downloadFile 微信安卓客户端 6 2

wx.downloadFile仅仅使用如下代码,未设置filePath属性,下载文件为excel文件

开发工具和手机端正常返回值,可以获取xls格式的excel文件

{"tempFilePath":"http://tmp/wx8b028dc4ce21075e.o6zAJs6wqcYV0xemx8m88l0fPi3U.UKiBI48sFRlO309bc07de1e2f959b8f9e96749114fca.xls","statusCode":200,"header":{"Server":"openresty","Date":"Mon, 31 Aug 2020 15:03:45 GMT","Content-Type":"application/vnd.ms-excel","Content-Length":"4608","Connection":"close","Last-Modified":"Mon, 31 Aug 2020 15:03:45 GMT","Accept-Ranges":"bytes","Set-expires=Tue, 31-Aug-21 15:03:45 GMT; max-age=31536000; path=/; version=1"},"cookies":[expires=Tue 31-Aug-21 15:03:45 GMT; max-age=31536000; path=/; version=1"],"errMsg":"downloadFile:ok"}

但是在pc端微信端口进入的小程序返回值为txt的文件与xls文件格式都不一样,导致无法找到缓存文件

wx.downloadFile({
   url: url,
      success(res) {}
})

{"cookies":["BAEID=07F2CC985DD480633105B86795594080; expires=Tue 31-Aug-21 14:58:18 GMT; max-age=31536000; path=/; version=1"],"header":{"accept-ranges":"bytes","content-length":"4608","content-type":"application/vnd.ms-excel","date":"Mon, 31 Aug 2020 14:58:18 GMT","etag":"\"5f4d100a-1200\"","last-modified":"Mon, 31 Aug 2020 14:58:18 GMT","server":"nginx", expires=Tue, 31-Aug-21 14:58:18 GMT; max-age=31536000; path=/; version=1","status":"200"},"statusCode":200,"tempFilePath":"wxfile://temp/15.txt","errMsg":"downloadFile:ok"}

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签