简介
本文档提供关于海报接口的 API 概览以及 SDK 示例代码。
说明:
上传文件解析模板接口
接口文档及示例函数名
API 文档 | 示例函数名 |
PutPosterproductionTemplate |
示例代码
func PutPosterproductionTemplate() {u, _ := url.Parse("https://test-1234567890.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-1234567890.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})PosterproductionTemplate := &cos.PosterproductionTemplateOptions{Input: &cos.PosterproductionInput{Object: "input/sample.psd",},Name: "test",}PutPosterproductionRes, _, err := c.CI.PutPosterproductionTemplate(context.Background(), PosterproductionTemplate)log_status(err)fmt.Printf("%+v\\n", PutPosterproductionRes)fmt.Printf("%+v\\n", &PutPosterproductionRes.Template)}
查询海报模板
接口文档及示例函数名
API 文档 | 示例函数名 |
GetPosterproductionTemplate |
示例代码
func GetPosterproductionTemplate() {u, _ := url.Parse("https://test-1234567890.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-1234567890.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})PutPosterproductionRes, _, err := c.CI.GetPosterproductionTemplate(context.Background(), "6444f12ae24d596cdbd774fb")log_status(err)fmt.Printf("%+v\\n", PutPosterproductionRes)fmt.Printf("%+v\\n", &PutPosterproductionRes.Template)}
批量拉取海报模板
接口文档及示例函数名
API 文档 | 示例函数名 |
GetPosterproductionTemplates |
示例代码
func GetPosterproductionTemplates() {u, _ := url.Parse("https://test-1234567890.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-1234567890.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})opt := &cos.DescribePosterproductionTemplateOptions{PageNumber: 1,PageSize: 10,}PutPosterproductionRes, _, err := c.CI.GetPosterproductionTemplates(context.Background(), opt)log_status(err)fmt.Printf("%+v\\n", PutPosterproductionRes)fmt.Printf("%+v\\n", &PutPosterproductionRes.TemplateList)}
提交海报合成任务
接口文档及示例函数名
API 文档 | 示例函数名 |
InvokePosterProductionJob |
示例代码
func InvokePosterProductionJob() {u, _ := url.Parse("https://test-1234567890.cos.ap-chongqing.myqcloud.com")cu, _ := url.Parse("https://test-1234567890.ci.ap-chongqing.myqcloud.com")b := &cos.BaseURL{BucketURL: u, CIURL: cu}c := cos.NewClient(b, &http.Client{Transport: &cos.AuthorizationTransport{SecretID: os.Getenv("COS_SECRETID"),SecretKey: os.Getenv("COS_SECRETKEY"),Transport: &debug.DebugRequestTransport{RequestHeader: true,RequestBody: true,ResponseHeader: true,ResponseBody: true,},},})type autoInfo struct {TextMain string `xml:"text_main,omitempty"`TextSub string `xml:"text_sub,omitempty"`}info := autoInfo{TextMain: "父亲节快乐",TextSub: "献给最伟大的父亲!!!",}createJobOpt := &cos.CreateJobsOptions{Tag: "PosterProduction",Operation: &cos.MediaProcessJobOperation{PosterProduction: &cos.PosterProduction{TemplateId: "6444f12ae24d596cdbd774fb",Info: info,},Output: &cos.JobOutput{Region: "ap-chongqing",Bucket: "test-1234567890",Object: "poster/PosterProduction2.jpg",},},CallBack: "https://demo.org/callback",}createJobRes, _, err := c.CI.CreateJob(context.Background(), createJobOpt)log_status(err)fmt.Printf("%+v\\n", createJobRes.JobsDetail)}