控制台指南

最佳实践

开发者指南

API 文档

SDK 文档

盲水印

最近更新时间:2021-05-14 10:49:57

简介

本文档提供关于盲水印相关的 API 概览以及 SDK 示例代码。

SDK API 参考

SDK 所有接口的具体参数与方法说明,请参考 SDK API

添加盲水印

功能说明

盲水印支持在上传时添加以及下载时添加。

示例代码一:上传时添加盲水印

PutObjectRequest request = new PutObjectRequest(bucket, key, srcPath);

JObject o = new JObject();
// 不返回原图
o["is_pic_info"] = 0;
JArray rules = new JArray();
JObject rule = new JObject();
rule["bucket"] = bucket;
rule["fileid"] = key;
//处理参数,规则参见:https://cloud.tencent.com/document/product/436/46782
rule["rule"] = "watermark/3/type/<type>/image/<imageUrl>/text/<text>/level/<level>";
rules.Add(rule);
o["rules"] = rules;

string ruleString = o.ToString(Formatting.None);
request.SetRequestHeader("Pic-Operations", ruleString);
//执行请求
PutObjectResult result = cosXml.PutObject(request);

说明:

更多完整示例,请前往 GitHub 查看。

示例代码二:下载时添加盲水印

GetObjectRequest getObjectRequest = new GetObjectRequest(bucket, key, localDir, localFileName);
//处理参数,规则参见:https://cloud.tencent.com/document/product/436/46782
getObjectRequest.SetQueryParameter("watermark/3/type/<type>/image/<imageUrl>/text/<text>", null);

GetObjectResult result = cosXml.GetObject(getObjectRequest);

说明:

更多完整示例,请前往 GitHub 查看。

目录