openapi.security.imgSecCheck返回41005错误?
从小程序云函数调用imgSecCheck()时一直报41005错误,但是对应的media已经按文档设置。
errCode: 41005 | errMsg: openapi.security.imgSecCheck:fail media data missing hint: [xKvxiA04673955]
错误信息提示
imgSecCheck() is triggered from cloud with event:
{action: "imgSecCheck", contentType: "image/jpg", buffer: {…}}
action: "imgSecCheck"
buffer: {type: "Buffer", data: Array(15006)}
contentType: "image/jpg"
__proto__: Object
exception during imgSecCheck, e: Error: errCode: 41005 | errMsg: openapi.security.imgSecCheck:fail media data missing hint: [xKvxiA04673955]
at callWXOpenAPI (/.../cloudfunctions/openapi/node_modules/wx-server-sdk/index.js:2267:31)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async imgSecCheck (/.../cloudfunctions/openapi/index.js:43:15)
小程序云开发服务端代码段
// 图片内容检测
async function imgSecCheck(event) {
console.debug('imgSecCheck() is triggered from cloud with event: ', event)
try {
let res = await cloud.openapi.security.imgSecCheck({
media: {
contentType: event.contentType, // 'image/png',
value: event.value, // Buffer
}
})
return res
}
catch (e) {
console.error('exception during imgSecCheck, e: ', e)
return e
}
}