开发者工具 stable 1.03.2012120 writeFile 报错, 为啥?
发布于 7 年前 作者 luoguiying 5256 次浏览 来自 问答
// 打开微信开发者工具 console, 粘贴下面代码 👇

// 在 wechat_devtools_1.05.2101052 版本正常
// 在 wechat_devtools_1.03.2012120(稳定版)版本报错

function test(base64data, cb) {
  const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64data) || []
  if (!format) {
    return new Error('ERROR_BASE64SRC_PARSE')
  }
  const filePath = `${wx.env.USER_DATA_PATH}/abc.${format}`
  const buffer = wx.base64ToArrayBuffer(bodyData)
  const fsm = wx.getFileSystemManager()
  fsm.writeFile({
    filePath,
    data: buffer,
    encoding: 'binary',
    success() {
      cb(true, filePath)
    },
    fail(err) {
      console.error(err)
      cb(false)
    }
  })
}
const data = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4Q32RXhpZgAATU0AKgAAAAgABQEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAAITAAMAAAABAAEAAIdpAAQAAAABAAAAWgAAALQAAABIAAAAAQAAAEgAAAABAAeQAAAHAAAABDAyMjGRAQAHAAAABAECAwCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAAQCgAwAEAAAAAQAAAEWkBgADAAAAAQAAAAAAAAAAAAYBAwADAAAAAQAGAAABGgAFAAAAAQAAAQIBGwAFAAAAAQAAAQoBKAADAAAAAQACAAACAQAEAAAAAQAAARICAgAEAAAAAQAADNoAAAAAAAAASAAAAAEAAABIAAAAAf/Y/9sAhAABAQEBAQECAQECAwICAgMEAwMDAwQFBAQEBAQFBgUFBQUFBQYGBgYGBgYGBwcHBwcHCAgICAgJCQkJCQkJCQkJAQEBAQICAgQCAgQJBgUGCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQn/3QAEAAr/wAARCAArAKADASIAAhEBAxEB/8QBogAAAQUBAQEBAQEAAAAAAAAAAA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DOqBDoi/pf8n/gCgRztH4GeIa9w/NEeN/8AwerJ5skT/wDlz/zjQoSPjb8KddKT3+X5q0I3tdVCYXg82TmxY3Ov+SACwxEzkxDS6JiMCR2kZW5IZml7WSbGLTwE5+RNB70gTy80xA5QM5wCRX61pH8CXfEtMDYUMzm6GSxKJFfKTZwgAdM/UTG8URclUiIlmDMe6IzYnQS7xnbma/DAPUn/APCUhFHJZ2ogiYXPLRFniDREOkLLiuQYMc+HKsUETBkM/aunMTJPM7C3mbpOq8+2o/O3D0fy1g5PbeAmJpc8ERDkwn7snM8w8PkqYyIS4TnNaaiGR/wieCA055lNPqmbEkwf2c73dBR7CPoLKgCAan/lZhl8MD4P7pO8nIQy+bCykQ4uOgs8uc+lITPzYwyAEuD57qhxlTwAdcLlYwEqpI6kKSA+NgkmXB62xpo4IIz2f/hQSHurFUyjye2kFcJggImgkmZjOiKtPs9x7m6IYRAyLFnYIvu3gngiF4aMhu9Ous81AIhGexQwUwZYuG89PLaSoqJRTxIf/rr/2Q=='
test(data, (ok, _) => {
  console.log('status:', ok)
})

错误信息:

2 回复

是啊升级完了就报错了,退回上个版本就没事

你好,真机正常吗?请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部