code: function base64Image(base64Data, dir, options) {
      if(typeof dir === 'object'){
          options = dir
          dir = ''
      }
  
      publicDir = path.resolve(dir || 'public')
  
      let dest = ''
      let ext = '.png'
      let { destination, filename } = Object.assign({
          destination: path.join(publicDir, 'upload', 'image'),
          filename: Date.now() + (Math.random().toString().substr(2,6))
      }, options || {})
  
      base64Data = base64Data.replace(/^data:image\/(\w+);base64,/, (all, e) => {
          ext = e === 'jpeg' ? '.jpg' : '.' + e
          return ''
      })
      filename += ext
      dest = path.join(destination, filename)
  
      mkdirsSync(destination)
      fs.writeFileSync(dest, base64Data, 'base64')
      const stat = fs.statSync(dest)
      return { originalname: '', filename, path: dest, size: stat.size }
  }
docs: 保存base64类型图片