The WeChat mini program was reviewed and rejected. The reason for rejection was that the pictures uploaded by the user may have illegal or illegal issues, and the program must have an audit mechanism.
The solution is as follows (cloud development):
config.json
{ "permissions": { "openapi": [ "security.imgSecCheck" ] } }
Cloud function
const cloud = require('wx-server-sdk') cloud.init() exports.main = async (event, context) => { const { value } = event; try { const res = await cloud.openapi.security.imgSecCheck({ media: { header: { 'Content-Type': 'application/octet-stream'}, contentType: 'image/png', value: Buffer.from(value) } }) return res; } catch (err) { return err; } }
js
ChooseImage() { wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album'], success: (res) => { if (res.tempFiles[0] && res.tempFiles[0].size > 1024 * 1024) { wx.showToast({ title: '图片不能大于1M', icon: 'none' }) return; } //校验图片 wx.getFileSystemManager().readFile({ filePath: res.tempFilePaths[0], success: buffer => { console.log(buffer.data) wx.cloud.callFunction({ name: 'checkImg', data: { value: buffer.data } }).then( imgRes => { if (imgRes.result.errCode == '87014') { wx.showToast({ title: '图片含有违法违规内容', icon: 'none' }) return } else { //图片正常 if (this.data.imgList.length != 0) { this.setData({ imgList: this.data.imgList.concat(res.tempFilePaths) }) } else { this.setData({ imgList: res.tempFilePaths }) } } } ) }, fail: err => { console.log(err) } }) } }); },
Recommended tutorial: "微信小program"
The above is the detailed content of WeChat applet calls image security API. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools