简介
本文档提供关于盲水印的相关的 API 概览以及 SDK 示例代码。
添加盲水印
功能说明
盲水印支持在上传时添加和下载时添加。
示例代码一:上传时添加盲水印
const filePath = "temp-file-to-upload"
cos.putObject({
Bucket: 'examplebucket-1250000000',
Region: 'COS_REGION',
Key: 'exampleobject',
Body: fs.createReadStream(filePath),
Headers: {
'Pic-Operations': '{"is_pic_info": 1, "rules": [{"fileid": "desample_photo.jpg", "rule": "watermark/3/type/1/image/aHR0cDovL2V4YW1wbGVzLTEyNTEwMDAwMDQucGljc2gubXlxY2xvdWQuY29tL3NodWl5aW4uanBn"}]}'
},
}, function(err, data) {
console.log(err || data);
});
示例代码二:下载时添加盲水印
cos.getObject({
Bucket: 'examplebucket-1250000000',
Region: 'COS_REGION',
Key: 'exampleobject',
QueryString: 'watermark/3/type/1/image/aHR0cDovL2V4YW1wbGVzLTEyNTEwMDAwMDQucGljc2gubXlxY2xvdWQuY29tL3NodWl5aW4uanBn',
}, function (err, data) {
console.log(err || data);
fs.writeFileSync('filepath', data.Body);
});
本页内容是否解决了您的问题?