遇到了同样的问题,不过后来我解决了,可做一下参考 https://developers.weixin.qq.com/community/develop/article/doc/00080e25344040ed10693e8df56813
downloadFile 为什么二级文件路径报错 permission denied?在wx.env.USER_DATA_PATH目录下创建了一个文件夹: [代码]const dataPath = wx.env.USER_DATA_PATH[代码] [代码]this[代码][代码].downloadDir = dataPath + [代码][代码]"/downloads"[代码] [代码]fs.mkdirSync([代码][代码]this[代码][代码].downloadDir)[代码]按照如下方式使用wx.downloadFile下载文件报出错误:permission denied,open "http://usr/downloads/sample.mp4" [代码]let downloadPath = [代码][代码]this[代码][代码].downloadDir + [代码][代码]'/'[代码] [代码]+ url.getFileName(resource)[代码] [代码]wx.downloadFile({[代码] [代码] [代码][代码]url: resource,[代码] [代码] [代码][代码]filePath: downloadPath,[代码] [代码] [代码][代码]success(res) {[代码] [代码] [代码][代码]console.log([代码][代码]'downloader'[代码][代码], res)[代码] [代码] [代码][代码]}[代码] [代码] [代码][代码]})[代码]如果 downloadPath = wx.env.USER_DATA_PATH + '/' + url.getFileName(resource),则成功通过。这是为什么呢?一级路径能允许,二级路径不可以?
2019-10-30