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),则成功通过。这是为什么呢?一级路径能允许,二级路径不可以?
2 回复
遇到了同样的问题,不过后来我解决了,可做一下参考
https://developers.weixin.qq.com/community/develop/article/doc/00080e25344040ed10693e8df56813