Polyv Help Center

Help Center

Upload All Decoration Image Materials for a Channel

Updated: 2022-09-02 18:08:07

Interface Description

1、接口用于上传图片素材,同时获取图片地址
2、(type, timestamp, appId)参与sign签名,并和sign一起通过post表单传递,文件通过二进制流提交到服务器端。
2、接口支持https协议

Interface URL

http://api.polyv.net/live/v3/common/upload-image

Request Method

POST

Interface Constraints

  1. The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls have frequency limits. Click for details

Request Parameter Description

Parameter Required Type Description
appId true String Account appId [See Get Secret Key]
timestamp true Long Current 13-digit millisecond timestamp, valid for 3 minutes
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. 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]
file true File Image files, supports uploading up to 6 files simultaneously
type true String Upload image type [See Type Parameter Description]
Type Parameter Description
Type Value Description
coverImage Channel icon, recommended size 140 x 140, supports jpg, jpeg, png formats, file size no more than 2M
splashImage Live stream guide image, recommended size 750 x 1334, supports jpg, jpeg, png formats, file size no more than 2M
logoImage Player logo, recommended size no larger than 140 x 50, supports jpg, jpeg, png formats, file size no more than 2M
adminAvatar Chat room admin avatar, recommended size 140 x 140, file size no more than 2M
assistantAvatar Assistant avatar, recommended size 140 x 140, file size no more than 2M
authCodeImage Authorized viewing QR code image, maximum size no more than 200K
warmImage Warm-up image, recommended size 1280 x 720, file size no more than 2M, supports jpg, jpeg, png, gif formats
adImage Ad banner image, recommended size 750 x 120, supports png, jpg and other formats, maximum size no more than 2M
startAdImage Pre-roll ad image, recommended size 1280 x 720, file size no more than 4M
stopAdImage Pause ad image, recommended size 1280 x 720, file size no more than 4M
goodImage Tip icon, recommended size 180 x 180, file size no more than 300k
invitationImage Invitation card image, recommended size 750 x 1334, supports jpg, jpeg, png formats, file size no more than 4M
menuImage Channel menu image, maximum size no more than 2M

Example

http://api.polyv.net/live/v3/common/upload-image

Form Parameters:

appId=frlr1zazn3&sign=43029B62D712F53C0383F0F16E7C0848&type=logoImage&timestamp=1621842926851

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure [See Global Error Description]
status String Response status text
message String Response description message, when code is 400 or 500, provides auxiliary error reason
data Array On successful request, returns a list of image URLs; on failure, returns empty

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click here to download source code. After downloading, add it to your own source code project. HttpUtil.java and LiveSignUtil.java in the test cases are included in the downloaded file.

It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified packaging and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.

private static final Logger log = LoggerFactory.getLogger(WebSettingTest.class);
/**
 * 上传频道所有装修图片素材
 * @throws IOException
 */
@Test
public void testUploadImage() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId=super.appId;
    String appSecret=super.appSecret;
    String userId = super.userId;
    String timestamp=String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v3/common/upload-image";
    String type = "logoImage";
    List<File> fileList = new ArrayList<>();
    String path1 = getClass().getResource("/file/").getPath() + "dog.jpeg";
    String path2 = getClass().getResource("/file/").getPath() + "222.jpeg";
    File file = new File(path1);
    File file2 = new File(path2);
    fileList.add(file);
    fileList.add(file2);

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);
    Map<String, List<File>> fileListMap = new HashMap<>();
    fileListMap.put("file",fileList);
    requestMap.put("type",type);
    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.postMultipleFile(url,requestMap,fileListMap,"utf-8");
    log.info("测试上传频道所有装修图片素材:{}",response);
    //do somethings

}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "code":200,
    "status":"success",
    "message":"",
    "data":[
        "//liveimages.videocc.net/uploaded/images/2021/03/fwni4qhpdz.jpeg",
        "//liveimages.videocc.net/uploaded/images/2021/03/fwni4qjq5y.jpeg"
    ]
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询
在线咨询