简介
本文档提供关于文档审核的相关的 API 概览以及 SDK 示例代码。
创建任务
PutDocumentAuditingJob 接口用来提交一个文档审核任务。您可以通过主动设置回调地址接收审核信息,也可以通过 JobId 进行查询。
方法原型
func (s *CIService) PutDocumentAuditingJob(ctx context.Context, opt *PutDocumentAuditingJobOptions) (*PutDocumentAuditingJobResult, *Response, error)
请求示例
// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息// CI 任务需要提供 CIURLbu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")b := &cos.BaseURL{BucketURL: bu, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("SECRETID"),SecretKey: os.Getenv("SECRETKEY"),}})opt := &cos.PutDocumentAuditingJobOptions{InputUrl: "http://www.example.com/doctest.docx",InputType: "docx",Conf: &cos.DocumentAuditingJobConf{},}res, _, err := c.CI.PutDocumentAuditingJob(context.Background(), opt)
参数说明
type PutDocumentAuditingJobOptions struct {InputObject stringInputUrl stringInputType stringInputDataId stringInputUserInfo *UserExtraInfoConf *DocumentAuditingJobConf}type UserExtraInfo struct {TokenId stringNickname stringDeviceId stringAppId stringRoom stringIP stringType string}type DocumentAuditingJobConf struct {Callback stringBizType string}
参数名称 | 参数描述 | 类型 | 是否必填 |
InputObject | 存储在 COS 存储桶中的文件名称,例如在目录 test 中的文件test.doc,则文件名称为 test/test.doc 。Object 和 Url 只能选择其中一种。 | String | 否 |
InputUrl | 文档文件的链接地址,例如 http://www.example.com/doctest.doc ,Object 和 Url 只能选择其中一种。 | String | 否 |
InputType | 指定文档文件的类型,如未指定则默认以文件的后缀为类型。如果文件没有后缀,该字段必须指定,否则会审核失败。例如:doc、docx、ppt、pptx 等。 | String | 否 |
InputDataId | 文档标识,该字段在结果中返回原始内容,长度限制为512字节。 | String | 否 |
InputUserInfo | 用户业务字段。 | Object | 否 |
Conf | 审核规则配置。 | Struct | 是 |
BizType | String | 否 | |
Callback | 审核结果可以回调形式发送至您的回调地址,支持以 http:// 或者 https:// 开头的地址,例如:http://www.callback.com 。 | String | 否 |
结果说明
调用 PutDocumentAuditingJob 函数,会解析 api 返回的 xml 内容到 PutDocumentAuditingJobResult 结构,具体返回参数可查看 提交文档审核任务 文档。
查询任务
GetDocumentAuditingJob 接口用来查询指定的文档审核任务。您可以根据文档审核任务的 JobId 来查询文档审核结果。
方法原型
func (s *CIService) GetDocumentAuditingJob(ctx context.Context, jobid string) (*GetDocumentAuditingJobResult, *Response, error)
请求示例
// 将 examplebucket-1250000000 和 COS_REGION 修改为真实的信息// CI 任务需要提供 CIURLbu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")b := &cos.BaseURL{BucketURL: bu, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("SECRETID"),SecretKey: os.Getenv("SECRETKEY"),}})jobId := "sdce25f391a72e11eb99f********"res, _, err := c.CI.GetDocumentAuditingJob(context.Background(), jobId)
参数说明
参数名称 | 参数描述 | 类型 |
jobId | 任务 ID。 | String |
结果说明
调用 GetDocumentAuditingJob 函数,会解析 api 返回的 xml 内容到 GetDocumentAuditingJobResult 结构,具体返回参数可查看 查询文档审核任务结果 文档。