@@ -1636,7 +1636,7 @@ function CIExample3(){
16361636 Bucket : config . Bucket ,
16371637 Region : config . Region ,
16381638 Key : 'example_photo.png' ,
1639- QueryString : ` imageMogr2/thumbnail/200x/` ,
1639+ QueryString : ' imageMogr2/thumbnail/200x/' ,
16401640 } ,
16411641 function ( err , data ) {
16421642 if ( data ) {
@@ -1659,7 +1659,7 @@ function CIExample4(){
16591659 Bucket : config . Bucket ,
16601660 Region : config . Region ,
16611661 Key : 'photo.png' ,
1662- QueryString : ` imageMogr2/thumbnail/200x/` ,
1662+ QueryString : ' imageMogr2/thumbnail/200x/' ,
16631663 Expires : 1800 ,
16641664 Sign : true ,
16651665 } ,
@@ -1673,7 +1673,7 @@ function CIExample4(){
16731673 Bucket : config . Bucket ,
16741674 Region : config . Region ,
16751675 Key : 'photo.png' ,
1676- QueryString : ` imageMogr2/thumbnail/200x/` ,
1676+ QueryString : ' imageMogr2/thumbnail/200x/' ,
16771677 Sign : false ,
16781678 } ,
16791679 function ( err , data ) {
@@ -2606,6 +2606,25 @@ function TriggerWorkflow() {
26062606 } ) ;
26072607}
26082608
2609+ // 同步审核存储桶里的图片对象
2610+ function SyncAuditImageObject ( ) {
2611+ cos . request ( {
2612+ Bucket : config . Bucket , // Bucket 格式:test-1250000000
2613+ Region : config . Region ,
2614+ Key : 'audit/1.jpg' ,
2615+ Method : 'GET' ,
2616+ Query : {
2617+ 'ci-process' : 'sensitive-content-recognition' ,
2618+ // 'detect-url': '<url>',
2619+ // 'biz-type': '<type>', // 审核策略 id
2620+ // 'detect-type': 'porn,ads', // 审核类型 porn,ads
2621+ // 'interval': 5, // gif截取间隔帧数
2622+ // 'max-frames': 5, // gif最大截帧数
2623+ }
2624+ } , function ( err , data ) {
2625+ console . log ( err || data ) ;
2626+ } ) ;
2627+ }
26092628
26102629/**
26112630 * 获取私有 M3U8 ts 资源的下载授权
@@ -2625,6 +2644,118 @@ function GetPrivateM3U8() {
26252644 } ) ;
26262645}
26272646
2647+ // 同步审核任意图片 Url
2648+ function SyncAuditImageUrl ( ) {
2649+ cos . request ( {
2650+ Bucket : config . Bucket , // Bucket 格式:test-1250000000
2651+ Region : config . Region ,
2652+ Method : 'GET' ,
2653+ Query : {
2654+ 'ci-process' : 'sensitive-content-recognition' ,
2655+ 'detect-url' : 'https://ftp.bmp.ovh/imgs/2021/09/ee4e63607465ed8d.jpg' ,
2656+ // 'biz-type': '<type>', // 审核策略 id
2657+ // 'detect-type': 'porn,ads', // 审核类型 porn,ads
2658+ // 'interval': 5, // gif截取间隔帧数
2659+ // 'max-frames': 5, // gif最大截帧数
2660+ }
2661+ } , function ( err , data ) {
2662+ console . log ( err || data ) ;
2663+ } ) ;
2664+ }
2665+
2666+ // 批量同步审核任意图片 Url
2667+ function SyncAuditImageUrls ( ) {
2668+ cos . request ( {
2669+ Url : `https://${ config . Bucket } .ci.${ config . Region } .myqcloud.com/image/auditing` ,
2670+ Method : 'POST' ,
2671+ Headers : {
2672+ 'content-type' : 'application/xml'
2673+ } ,
2674+ Body : json2xml ( {
2675+ Request : {
2676+ Input : [ {
2677+ Object : 'audit/1.jpg' ,
2678+ // DataId: '1', // 审核序号
2679+ // Url: '<url>',
2680+ // Interval: 5,
2681+ // MaxFrames: 5,
2682+ } , {
2683+ Object : 'audit/2.jpg' ,
2684+ } ] ,
2685+ Conf : {
2686+ DetectType : 'Porn,Ads' ,
2687+ // Callback: '<url>', // 回调地址
2688+ // BizType: '', // 审核策略
2689+ } ,
2690+ } ,
2691+ } ) ,
2692+ } , function ( err , data ) {
2693+ console . log ( err || data . Response . JobsDetail ) ;
2694+ } ) ;
2695+ }
2696+
2697+ // 审核文本内容
2698+ function SyncAuditTextContent ( ) {
2699+ cos . request ( {
2700+ Url : `https://${ config . Bucket } .ci.${ config . Region } .myqcloud.com/text/auditing` ,
2701+ Method : 'POST' ,
2702+ Headers : {
2703+ 'content-type' : 'application/xml'
2704+ } ,
2705+ Body : json2xml ( {
2706+ Request : {
2707+ Input : {
2708+ Content : Buffer . from ( '高潮' ) . toString ( 'base64' ) ,
2709+ } ,
2710+ Conf : {
2711+ DetectType : 'Porn,Terrorism,Politics,Ads,Illegal,Abuse' ,
2712+ // Callback: '<url>', // 回调地址
2713+ // BizType: '', // 审核策略
2714+ } ,
2715+ } ,
2716+ } ) ,
2717+ } , function ( err , data ) {
2718+ console . log ( err || data . Response . JobsDetail ) ;
2719+ } ) ;
2720+ }
2721+
2722+ // 提交图片审核任务
2723+ function CreateAuditJob ( ) {
2724+ var objectKey = 'audit/1.jpg' ;
2725+ var objectType = 'image' ; // image/audio/video/text/document
2726+ cos . request ( {
2727+ Url : `https://${ config . Bucket } .ci.${ config . Region } .myqcloud.com/${ objectType } /auditing` ,
2728+ Method : 'POST' ,
2729+ Headers : {
2730+ 'content-type' : 'application/xml'
2731+ } ,
2732+ Body : json2xml ( {
2733+ Request : {
2734+ Input : {
2735+ Object : objectKey ,
2736+ } ,
2737+ Conf : {
2738+ DetectType : 'Porn,Ads' ,
2739+ // Callback: '<url>', // 回调地址
2740+ // BizType: '', // 审核策略
2741+ } ,
2742+ } ,
2743+ } ) ,
2744+ } , function ( err , data ) {
2745+ console . log ( err || data . Response . JobsDetail ) ;
2746+ } ) ;
2747+ }
2748+
2749+ // 查询审核任务结果
2750+ function DescribeAuditJob ( ) {
2751+ var jobId = 'st3bb560af647911ec919652540024deb5' ;
2752+ cos . request ( {
2753+ Url : `https://${ config . Bucket } .ci.${ config . Region } .myqcloud.com/text/auditing/${ jobId } ` ,
2754+ } , function ( err , data ) {
2755+ console . log ( err || data . Response . JobsDetail ) ;
2756+ } ) ;
2757+ }
2758+
26282759// 存储桶操作
26292760// getService();
26302761// getAuth();
@@ -2750,3 +2881,10 @@ function GetPrivateM3U8() {
27502881//UpdateWorkflow();
27512882//TriggerWorkflow();
27522883//GetPrivateM3U8();
2884+
2885+ // SyncAuditImageObject()
2886+ // SyncAuditImageUrl()
2887+ // SyncAuditImageUrls()
2888+ // SyncAuditTextContent()
2889+ // CreateAuditJob()
2890+ // DescribeAuditJob()
0 commit comments