小程序保存下载文件到可写目录
发布于 6 年前 作者 zgu 6123 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

wx.saveFile({

tempFilePath: tempFilePath,

success(res) {

var systemManager = wx.getFileSystemManager()

//下载目录设置

const fs = wx.getFileSystemManager()

var fp = systemManager.copyFileSync(res.savedFilePath, `${wx.env.USER_DATA_PATH}`)

console.log(fp)

wx.openDocument({

filePath: fp,

fileType: “docx”,

success: function (res) {

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

},

fail: function (res) {

console.log(res);

},

complete: function (res) {

console.log(res);

}

});

报错

thirdScriptError

copyFileSync:fail permission denied, copyFile “http://store/wxf200f9d8144d07a0.o6zAJs3EXKIhuS9qFfSIFdG7mG6w.mW5JpFwjB8IA5a0e5734ef9935bc32260c2426a19d62.word” -> “wx://usr”;at pages/searchResult/searchResult downloadFile function;at api saveFile success callback function

Error: copyFileSync:fail permission denied, copyFile “wx://store/wxf200f9d8144d07a0.o6zAJs3EXKIhuS9qFfSIFdG7mG6w.mW5JpFwjB8IA5a0e5734ef9935bc32260c2426a19d62.word” -> “wx://usr”

wx.saveFile保存之后的文件  我如何保存到 用户空间目录  然后手机文件夹 可以查看到这个文件

copyFileSync(res.savedFilePath, `${wx.env.USER_DATA_PATH}`)  这个为什么没权限写

1 回复
回到顶部