img.scanQRCode如何解析buffer?
发布于 7 年前 作者 weizhong 5976 次浏览 来自 官方Issues

// 小程序端

let buffer = wx.getFileSystemManager().readFileSync(filePath)

        wx.cloud.callFunction({
          name: 'imgCheck',
          data: {
            contentType: `image/jpeg`,
            buffer: buffer,
          }
        })

// 云端


    const res = await cloud.openapi.img.scanQRCode({

      img: {

        contentType: event.contentType,

        value: Buffer.from(event.buffer)

      }

    })





如上,

  1. errCode41005

  2. errMsg"openapi.img.scanQRCode:fail media data missing hint: [vYrSkA00211301]"

用相同的图片,用相同的处理方法,调用 cloud.openapi.security.imgSecCheck 方法没有问题,猜测是 scanQRCode 方法解析文件有问题?求官方看看

2 回复

Buffer.from(event.buffer) 换成 new Buffer(event.buffer) 试试

刚刚有问题,再试试 img 呢?

回到顶部