岛屿可以找到海
岛屿可以找到海

微信小程序报错:writeFile:fail themaximum size of the file storagelimit is exceeded

这两天用户突然给我说小程序配音功能无法使用了,我排查来排查去,能排查的地方都是正常的,然后我更新了一下小程序,记录了详细的错误才发现报错:writeFile:fail themaximum size of the file storagelimit is exceeded,怪不得用户生成的配音文件无法存储呢,因为微信这边设置了100mb的最大本地存储,超过了就无法再存储了,解决方案如下:

    //清理缓存、临时本地文件
    const fs = wx.getFileSystemManager();
    fs.readdir({
      dirPath:`${wx.env.USER_DATA_PATH}/`,
      success:(res)=>{
        res.files.forEach((item,index)=>{
            fs.unlink({
              filePath:`${wx.env.USER_DATA_PATH}/`+item,
              success:(res)=>{
                 
              },
              fail:(err)=>{
              
              }
            })
        })
      }
    })

可以在小程序加载后,清理一下本地文件,这样就不会超过100mb

没有标签
首页      代码技术学习      微信小程序报错:writeFile:fail themaximum size of the file storagelimit is exceeded

岛屿可以找到海

微信小程序报错:writeFile:fail themaximum size of the file storagelimit is exceeded
这两天用户突然给我说小程序配音功能无法使用了,我排查来排查去,能排查的地方都是正常的,然后我更新了一下小程序,记录了详细的错误才发现报错:writeFile:fail themaximum size of th…
扫描二维码继续阅读
2025-08-06