API | Description |
Submits file moderation job. | |
Queries the result of specified file moderation job. |
JobId
.using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitDocumentCensorJobModel {private CosXml cosXml;SubmitDocumentCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // Set the default region. For the abbreviations for COS regions, visit https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1..Build();string secretId = "SECRET_ID"; // `SecretId` of your TencentCloud API key. For more information on how to get it, visit https://console.tencentcloud.com/cam/capi.string secretKey = "SECRET_KEY"; // `SecretKey` of your TencentCloud API key. For more information on how to get it, visit https://console.tencentcloud.com/cam/capi.long durationSecond = 600; // Validity period of the request signature in secondsQCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}/// Submit the file moderation jobpublic string SubmitDocumentCensorJob(){// Bucket name, which must be in the format of `bucketname-APPID`. For more information on how to get the `APPID`, visit https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000"; // Note: To perform this operation, the bucket should have the content moderation feature enabled.SubmitDocumentCensorJobRequest request = new SubmitDocumentCensorJobRequest(bucket);request.SetUrl("url"); // URL of the file to be moderated, which should be replaced with that of the actual file.// The scene to be moderated, such as `Porn` (pornography) and `Ads` (advertising). You can pass in multiple types and separate them by comma, such as `Porn,Ads`.request.SetDetectType("Porn,Ads");// Execute the requestSubmitCensorJobResult result = cosXml.SubmitDocumentCensorJob(request);Console.WriteLine(result.GetResultInfo());Console.WriteLine(result.censorJobsResponse.JobsDetail.JobId);Console.WriteLine(result.censorJobsResponse.JobsDetail.State);Console.WriteLine(result.censorJobsResponse.JobsDetail.CreationTime);return result.censorJobsResponse.JobsDetail.JobId;}static void Main(string[] args){SubmitDocumentCensorJobModel m = new SubmitDocumentCensorJobModel();/// Submit the moderation jobstring JobId = m.SubmitDocumentCensorJob();}}}
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitDocumentCensorJobModel {private CosXml cosXml;SubmitDocumentCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // Set the default region. For the abbreviations for COS regions, visit https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1..Build();string secretId = "SECRET_ID"; // `SecretId` of your TencentCloud API key. For more information on how to get it, visit https://console.tencentcloud.com/cam/capi.string secretKey = "SECRET_KEY"; // `SecretKey` of your TencentCloud API key. For more information on how to get it, visit https://console.tencentcloud.com/cam/capi.long durationSecond = 600; // Validity period of the request signature in secondsQCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}/// Query the file moderation job resultpublic void GetDocumentCensorJobResult(string JobId){// Bucket name, which must be in the format of `bucketname-APPID`. For more information on how to get the `APPID`, visit https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000"; // Note: To perform this operation, the bucket should have the content moderation feature enabled.GetDocumentCensorJobRequest request = new GetDocumentCensorJobRequest(bucket, JobId);// Execute the requestGetDocumentCensorJobResult result = cosXml.GetDocumentCensorJob(request);Console.WriteLine(result.GetResultInfo());// Read the moderation resultConsole.WriteLine(result.resultStruct.JobsDetail.State);Console.WriteLine(result.resultStruct.JobsDetail.JobId);Console.WriteLine(result.resultStruct.JobsDetail.Suggestion);Console.WriteLine(result.resultStruct.JobsDetail.CreationTime);Console.WriteLine(result.resultStruct.JobsDetail.Url);Console.WriteLine(result.resultStruct.JobsDetail.PageCount);Console.WriteLine(result.resultStruct.JobsDetail.Labels);Console.WriteLine(result.resultStruct.JobsDetail.Labels.PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.Labels.PornInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.Url);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.Text);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PageNumber);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PornInfo.SubLabel);Console.WriteLine(result.resultStruct.JobsDetail.PageSegment.Results.PornInfo.Score);}static void Main(string[] args){SubmitDocumentCensorJobModel m = new SubmitDocumentCensorJobModel();/// Enter the `JobId` that is returned during moderation job submission and uniquely identifies this moderation jobstring JobId = "xxx";/// Query the moderation job resultm.GetDocumentCensorJobResult(JobId);}}}
Was this page helpful?