相同的问题,请问楼主解决了吗
云开发 security.imgSecCheck 调用响应错误使用云函数调用 security.imgSecCheck ,对图片进行鉴黄请求响应为: [代码]{[代码] [代码]errMsg: [代码][代码]"cloud.callFunction:ok",[代码] [代码]result:{[代码][代码] errCode: 41005[代码][代码] errMsg: [代码][代码]"openapi.security.imgSecCheck:fail media data missing hint: [9ZGoCA02628622]" [代码] [代码] }[代码] [代码]}[代码] 云函数代码如下: [代码]const cloud = require([代码][代码]'wx-server-sdk'[代码][代码])[代码] [代码]cloud.init();[代码] [代码]// 云函数入口函数[代码][代码]exports.main = (event) => {[代码][代码] [代码][代码]console.log(event);[代码][代码] [代码][代码]return[代码] [代码]cloud.openapi.security[代码][代码] [代码][代码].imgSecCheck({[代码][代码] [代码][代码]media: {[代码][代码] [代码][代码]contentType: [代码][代码]'image/png'[代码][代码],[代码][代码] [代码][代码]value: event.img[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码].then(result => {[代码][代码] [代码][代码]return[代码] [代码]result;[代码][代码] [代码][代码]})[代码][代码] [代码][代码].[代码][代码]catch[代码][代码](err => {[代码][代码] [代码][代码]return[代码] [代码]err;[代码][代码] [代码][代码]})[代码][代码]}[代码] 调用代码如下: [代码]uploadImg: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]this[代码][代码].selectImg().then(img => {[代码][代码] [代码][代码]console.log(img);[代码][代码] [代码][代码]return[代码] [代码]this[代码][代码].imgSecCheck(img);[代码][代码] [代码][代码]}).then(res => {[代码][代码] [代码][代码]console.log([代码][代码]"success:"[代码][代码], res);[代码][代码] [代码][代码]}).[代码][代码]catch[代码][代码](err => {[代码][代码] [代码][代码]console.log([代码][代码]"fail"[代码][代码], err);[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] // 选择图片并转为 buffer [代码] [代码][代码]selectImg: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]return[代码] [代码]new[代码] [代码]Promise((resolve, reject) => {[代码][代码] [代码][代码]wx.chooseImage({[代码][代码] [代码][代码]count: 1,[代码][代码] [代码][代码]sizeType: [[代码][代码]'original'[代码][代码], [代码][代码]'compressed'[代码][代码]],[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码][代码]let params = {[代码][代码] [代码][代码]filePath: res.tempFilePaths[0][代码][代码] [代码][代码]};[代码][代码] [代码][代码]wx.getFileSystemManager()[代码][代码] [代码][代码].readFile({[代码][代码] [代码][代码]filePath: res.tempFilePaths[0],[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]console.log([代码][代码]"readSuccess:"[代码][代码], res);[代码][代码] [代码][代码]resolve(res.data);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: err => {[代码][代码] [代码][代码]console.log([代码][代码]"readFail:"[代码][代码], err);[代码][代码] [代码][代码]reject(err);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]},[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码] // 调用云函数[代码] [代码][代码]imgSecCheck: [代码][代码]function[代码][代码](img) {[代码][代码] [代码][代码]return[代码] [代码]wx.cloud.callFunction({[代码][代码] [代码][代码]name: [代码][代码]"imgSecCheck"[代码][代码],[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]img: img[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码]
2019-08-20