微信小程序调用图片安全API(小程序加载图片)

本站:VPS参考评测推荐,专注分享VPS服务器优惠信息!若您是商家也可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
部分文章发布时间较久远,可能存在未知因素,购买时建议在本站搜索商家名称,可查看相关文章充分了解商家!若非中文页面可使用谷歌浏览器同步翻译!PayPal代付/收录合作

微信小程序审核被拒。拒绝的原因是用户上传图片可能存在违法问题,程序必须有审核机制。解决方案如下(云开发):config.json

{ 权限 :{ openapi :[ ;security.imgSecCheck ]}}云函数

const cloud = require( # 39;wx-server -SDK # 39;)cloud . init()exports . main = async(event,context)= gt;{ const { value } =事件;请尝试{ const RES = await cloud . open API . security . imgseccheck({ media:{ header:{ # 39;内容-类型 # 39;: '应用程序/octet -流 # 39;},内容类型: # 39;图片/png # 39;,value: Buffer.from(value) } })返回res} catch(err){ return err;}}js

choose image(){ wx . choose image({ count:1,size type:[ # 39;原创 # 39;, '压缩 # 39;],source type:[ # 39;相册 # 39;],成功:(RES)= gt;{ if(RES . temp files[0] ; res.tempFiles[0]。size gt1024 * 1024){ wx . show toast({ title: # 39;图片不能大于1M # 39,图标: # 39;无 # 39;})返回;}//查看图片wx.getfilesystemmanager()。readfile({ file path:RES . tempfile paths[0],success:buffer = >;{ console . log(buffer . data)wx . cloud . call function({ name: # 39;检查 # 39;,数据:{ value: buffer.data } })。然后(imgRes = gt{ if(imgres . result . errcode = = # 39;87014'){ wx . show toast({ title: # 39;图片包含非法内容 # 39;,图标: # 39;无 # 39;}) return} else {//图片正常if (this.data.imgList.length!= 0){ this . setdata({ img list:this . data . img list . concat(RES . tempfile paths)})} else { this . setdata({ img list:RES . tempfile paths })} } },fail:err = gt;{ console . log(err)} })});}、推荐教程:“微信小程序”以上是微信小程序调用图像安全API的详细内容。更多请关注本站其他相关文章!

本文由本站刊发,转载请注明:微信小程序调用图片安全API(小程序加载图片) https://本站.com/76971.html

推荐站内搜索:服务器租用多少钱一年、备案 查询、本地ip查询、工信部备案查询、公司域名如何备案、中文域名注册查询、香港云服务器、免费网站域名注册、腾讯云服务器、美国主机评论、