Help Center/
Content Moderation/
SDK Reference/
Using the Go SDK/
SDK Calling Example/
Moderation (Image)/
Image Moderation (Asynchronous Batch) (V2)/
Submitting a Task
Updated on 2023-07-17 GMT+08:00
Submitting a Task
- This section describes how to use the Image Moderation (Asynchronous Batch) SDK for submitting a task by AK/SK authentication.
Replace the AK/SK in the sample code with the actual AK/SK. You can set Urls in TaskSumbitReq to configure the URLs of the images to be reviewed, and then execute the code.
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" moderation "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/moderation/v2/region" ) func main() { //Enter your AK/SK. ak := "<YOUR AK>" sk := "<YOUR SK>" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := moderation.NewModerationClient( moderation.ModerationClientBuilder(). WithRegion(region.ValueOf("cn-north-4")). WithCredential(auth). Build()) request := &model.RunTaskSumbitRequest{} var listCategoriesbody = []model.TaskSumbitReqCategories{ model.GetTaskSumbitReqCategoriesEnum().PORN, } var listUrlsbody = []string{ "https://XXX.jpg", //Replace it with an image URL that can be accessed from the Internet. } request.Body = &model.TaskSumbitReq{ Categories: &listCategoriesbody, Urls: listUrlsbody, } response, err := client.RunTaskSumbit(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) }}
- If the task submission result is displayed on the console, the code is successfully executed.
RunTaskSumbitResponse {"result":{"job_id":"xxx"}} Process exiting with code: 0
Parent topic: Image Moderation (Asynchronous Batch) (V2)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot