我想在线预览doc文档,appid的域名和下载地址是一直的,装有ssl证书,官方说是先下载再打开,我的测试地址是下面这个,浏览器可以打开下载,而用小程序官方方法就不行,下载返回的数据:
errMsg:提示文件是空
statusCode:404,
搞不懂为什么,请教大神和官方。
doc地址:
https://www.smartkedou.com/wendanguanli/0/c683be60-69d5-4530-9968-0bd319e4cf09/c683be60-69d5-4530-9968-0bd319e4cf09__1/图片-b64646f5-9a9b-4237-8377-7cbf19a2f100.docx
wx.downloadFile({ url:"https://www.smartkedou.com/wendanguanli/0/c683be60-69d5-4530-9968-0bd319e4cf09/c683be60-69d5-4530-9968-0bd319e4cf09__1/图片-b64646f5-9a9b-4237-8377-7cbf19a2f100.docx", success: function (res) { console.log("下载成功!",res) var filePath = res.tempFilePath; if (res.statusCode === 200) { wx.openDocument({ filePath: filePath, success: function (res) { console.log("打开文档成功!", res) }, fail: function (res) { console.log("打开文档失败!", res) } }); } },fail(res){ console.log("下载失败!",res) } }) |

指定filetype参数试试。。。。。。
wx.openDocument({filePath: filePath,filetype: 'doc',success:function(res) {console.log("打开文档成功!", res)},fail:function(res) {console.log("打开文档失败!", res)}});}},fail(res){console.log("下载失败!",res)}})嗯,好像是因为名称中不能包含中文这些特殊符号,换成英文和数字下划线这种就可以正常下载预览。
请问解决了吗?
尽量文件名字用英文,不带特殊符号。
指定文档类型。
使用https。
即可解决。