API | 操作描述 |
对本地图片添加或提取盲水印并上传至存储桶 |
opt := &cos.ObjectPutOptions{nil,&cos.ObjectPutHeaderOptions{XOptionHeader: &http.Header{},},}pic := &cos.PicOperations{IsPicInfo: 1,Rules: []cos.PicOperationsRules{{FileId: ".jpg",Rule: "watermark/3/type/3/text/" + base64.StdEncoding.EncodeToString([]byte("testwatermark")),},},}opt.XOptionHeader.Add("Pic-Operations", cos.EncodePicOperations(pic))name := "test.jpg"filepath := "./test.jpg"res, _, err := c.CI.PutFromFile(context.Background(), name, filepath, opt)
name = "test.jpg"filepath := "watermark.jpg"_, err = c.CI.GetToFile(context.Background(), name, filepath, "watermark/3/type/3/text/"+base64.StdEncoding.EncodeToString([]byte("testwatermark")), nil)
opt := &cos.ObjectPutOptions{nil,&cos.ObjectPutHeaderOptions{XOptionHeader: &http.Header{},},}pic := &cos.PicOperations{IsPicInfo: 1,Rules: []cos.PicOperationsRules{{FileId: "format2.jpg",Rule: "watermark/4/type/3/text/" + base64.StdEncoding.EncodeToString([]byte("testwatermark")),},},}opt.XOptionHeader.Add("Pic-Operations", cos.EncodePicOperations(pic))name := "test2.jpg"_, err := c.Object.PutFromFile(context.Background(), name, filepath, opt)
本页内容是否解决了您的问题?