Upload Watermark
API Description
1、设置一级分类下或用户账号下所有视频的水印,设置成功后对新上传的视频生效
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/video/{userid}/watermarkSetting
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended to ensure security. API calls have frequency limits. See details
The watermark image must be in PNG or ASS format. If the width or height of a PNG image exceeds 256px, it will be scaled proportionally.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds, valid within 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must never be used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server for response data. See signature generation rules |
| image | true | File | Image to upload |
| cataid | false | String | Category ID, only sets watermarks for videos under a first-level category. If not provided, sets the watermark at the user level for all videos. |
| watermarkLocation | false | String | Watermark display position. Invalid for dynamic watermarks. 1: Top left 2: Top right 3: Bottom left 4: Bottom right |
| watermarkShow | false | String | Watermark status. Default is 0 if not provided. 0: Hidden 1: Visible |
Example
http://api.polyv.net/v2/video/1b448be323/watermarkSetting
Form parameters:
sign=BE988CCF37B7A32B137241D8134AA57071553006&cataid=1602300731843&ptime=1618279224027&watermarkLocation=3
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. See global error description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides additional error details. |
| data | Object | Returns true on success, or an empty string on failure. |
Java Request Example
For quick integration, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodVideoUploadTest.class);
/**
*上传水印
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testUploadWatermark() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/video/"+userId+"/watermarkSetting";
String path1 = getClass().getResource("/file/").getPath() + "cat.jpg";
File image = new File(path1);
String watermarkLocation = "3";
String cataid = "1602300731843";
//调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("watermarkLocation", watermarkLocation);
requestMap.put("cataid", cataid);
Map<String,File> fileMap = new HashMap<>();
fileMap.put("image",image);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.postFile(url,requestMap,fileMap,"utf-8");
log.debug("测试上传水印,{}", response);
//do somethings
}
Response Example
For system-wide global error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"success",
"data":true
}
Error Example
{
"code":400,
"status":"error",
"message":"sign can not be empty.",
"data":""
}
