云查毒接口

最近更新时间:2024-07-11 11:44:41

我的收藏

简介

本文档提供关于云查毒接口的 API 概览和 SDK 示例代码。
API
操作描述
用于提交一个病毒检测任务
用于查询一个病毒检测任务的状态或结果

提交病毒检测任务

功能说明

用于提交一个病毒检测任务。

方法原型

func (s *CIService) PutVirusDetectJob(ctx context.Context, opt *PutVirusDetectJobOptions) (*PutVirusDetectJobResult, *Response, error)

请求示例

示例一:存储桶文件查毒

// 将 examplebucket-1250000000 和 COS_REGION修改为真实的信息
// CI 任务需要提供CIURL
bu, _ := 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.PutVirusDetectJobOptions{
InputObject: "test.exe",
Conf: &VirusDetectJobConf{
DetectType: "Virus",
Callback: "http://callback.com/call_back_test",
},
}
res, _, err := c.CI.PutVirusDetectJob(context.Background(), opt)

示例二:URL 查毒

// 将 examplebucket-1250000000 和 COS_REGION修改为真实的信息
// CI 任务需要提供CIURL
bu, _ := 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.PutVirusDetectJobOptions{
InputUrl: "https://example.com/test.exe",
Conf: &VirusDetectJobConf{
DetectType: "Virus",
Callback: "http://callback.com/call_back_test",
},
}
res, _, err := c.CI.PutVirusDetectJob(context.Background(), opt)

参数说明

type PutVirusDetectJobOptions struct {
InputObject string
InputUrl string
Conf *VirusDetectJobConf
}

type VirusDetectJobConf struct {
DetectType string
Callback string
}
PutVirusDetectJobOptions 中的具体数据描述如下:
参数名称
描述
类型
是否必填
InputObject
存储在 COS 存储桶中的病毒文件名称。 注意:InputObjectInputUrl只能选择其中一种。
String
InputUrl
病毒文件的链接地址,例如 http://examplebucket-1250000000.cos.ap-shanghai.myqcloud.com/virus.doc 注意:InputObjectInputUrl只能选择其中一种。
String
Conf
操作配置。
Object
VirusDetectJobConf 中的具体数据描述如下:
参数名称
描述
类型
是否必填
DetectType
检测的病毒类型,当前固定为:Virus
String
Callback
回调地址,以http://或者https://开头的地址。
String

查询病毒检测任务结果

功能说明

用于查询一个病毒检测任务的状态或结果。

方法原型

func (s *CIService) GetVirusDetectJob(ctx context.Context, jobid string) (*GetVirusDetectJobResult, *Response, error)

请求示例

// 将 examplebucket-1250000000 和 COS_REGION修改为真实的信息
// CI 任务需要提供CIURL
bu, _ := 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 := "sace25f391a72e11eb99f********"
res, _, err := cos.GetVirusDetectJob(context.Background(), jobId)

参数说明

参数名称
描述
类型
是否必填
jobId
任务 ID。
String