writeFile:fail the maximum size of the f
发布于 6 年前 作者 yanshi 15195 次浏览 来自 问答

其他手机没问题, 我的测试机有问题,请问如何清理呢? 代码如何改进,手工如何清理一下手机, 要不测试机没法用了。 谢谢

writeFile:fail the maximum size of the file storage limit is exceeded"}

代码:

const mytmp = `${wx.env.USER_DATA_PATH}/${fileName}`

let xx = wx.getFileSystemManager()

let fffff = wx.base64ToArrayBuffer(bufferData.replace(/[\r\n]/g, “”))//.replace(/[\r\n]/g,"")

xx.writeFile({

filePath: mytmp,

encoding: ‘binary’,

data: fffff,

success: res => {

console.log(‘write file ok-----------’, fileName)

},

fail: err => {

console.log(err)

}

})

2 回复

无语十分钟。。。。。

答案:

let xx2 = wx.getFileSystemManager()

const basepath = `${wx.env.USER_DATA_PATH}`

xx2.readdir({

dirPath: basepath,/// 获取文件列表

success(res) {

console.log(res)

res.files.forEach((val) => { // 遍历文件列表里的数据

console.log(val)

xx2.unlink({

filePath: basepath + ‘/’ +val

});

})

},fail(err){

console.log(err)

},complete(){

console.log(‘complete’)

}

})

------ 这样就可以了

本地文件存储大小不够了

获取本地存储的文件列表,把不要的删除(本地存储大小限制应该是10M)

回到顶部