Polyv Help Center

Help Center

Upload Video Cover

Updated: 2025-10-10 12:02:04

API Description

1、通过分类id或者视频id上传视频封面图
2、接口支持https协议

API URL

http://api.polyv.net/v2/video/upload-cover-image

Request Method

POST

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

  2. Request parameters vids (video IDs) and cateIds (category IDs): When the vids parameter is provided, it takes precedence. When vids is not provided, cateIds is used. Both parameters cannot be empty simultaneously.

  3. Request parameters imageFile (image file), imageUrl (image HTTP link), imageBase64 (base64 encoded image data): For image upload, choose any one of the three. If multiple are provided, the first non-empty form is selected in the order of imageFile, imageUrl, imageBase64. Note: Only png, jpg, jpeg, gif, bmp image formats are supported, and the image size must not exceed 5MB.

Request Parameter Description

Parameter Name Required Type Description
userid true String POLYV VOD account ID. Refer to Get Secret Key for acquisition. Path: Official Website -> Login -> VOD (API Interface)
ptime true Long Current time in milliseconds timestamp, valid for 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 not be stored or used directly on the client. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See Signature Generation Rules
vids true String Video IDs, e.g., 1b448be3235552e5fafb16489eb01839_1. Multiple video IDs are separated by commas.
cateIds false String Category IDs, e.g., 1615536384688. This parameter is obtained from Get Categories and Subcategories. Multiple category IDs are separated by commas.
imageFile false File Image file
imageUrl false String Image link, supports http and https protocols
imageBase64 false String Base64 encoded image data

Example

http://api.polyv.net/v2/video/upload-cover-image

Form Parameters:

vids=1b448be32336069fd567bffc04f3e137_1%2C1b448be323a6a1a6c0c237856f555e88_1&imageUrl=https%3A%2F%2Fd.lanrentuku.com%2Fdown%2Fpng%2F1410%2Fseo-icons%2Fpenguin.png&sign=25108B8B497AD6FE6F1DB979A7FA617E10CE2252&cateIds=1615536384688&userid=1b448be323&ptime=1620286028736

Response Parameter Description

Parameter Name 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 auxiliary error reason.
data Object On success, returns large and small image links. See data field description. On failure, returns empty.

data Field Description

Java Request Example

For quick integration of basic code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source 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 pooling.

private static final Logger log = LoggerFactory.getLogger(VodVideoPosterTest.class);
/**
 * 上传视频封面
 */
@Test
public void testUploadPoster() 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/upload-cover-image";
    String vids = "1b448be32336069fd567bffc04f3e137_1,1b448be323a6a1a6c0c237856f555e88_1";
    String cateIds = "1615536384688";
    String filePath = getClass().getResource("/file/").getPath() + "poster.png";
    File imageFile = new File(filePath);
    String imageUrl = "https://d.lanrentuku.com/down/png/1410/seo-icons/penguin.png";

    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("userid", userid);
    requestMap.put("ptime", ptime);
    requestMap.put("vids", vids);
    requestMap.put("cateIds",cateIds);
    requestMap.put("imageUrl",imageUrl);
    Map<String,File> fileMap = new HashMap<>();
    fileMap.put("imageFile",imageFile);
    requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
    
    String response = HttpUtil.postFile(url,requestMap,fileMap,Constant.UTF8);
    log.debug("测试上传视频封面,{}", response);
    //do somethings
}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "message": "success",
    "data": {
        "imageUrlSmall": "http://img.videocc.net/uimage/1/1b448be323/first_image/645824f1-6697-4d14-b343-1ca5fdd4f574_s.png",
        "imageUrlBig": "http://img.videocc.net/uimage/1/1b448be323/first_image/645824f1-6697-4d14-b343-1ca5fdd4f574_b.png"
    }
}

Error Example

Incorrect Signature

{
    "code":400,
    "status":"error",
    "message":"the sign is not right",
    "data":""
}

Timestamp Expired

{
    "code":400,
    "status":"error",
    "message":"ptime is too old.",
    "data":""
}

Internal Error or Invalid Parameter Conversion Exception

{
    "code": 500,
    "status": "fail",
    "message": "undefined error",
    "data": null
}
联系客服,在线咨询
在线咨询