Asynchronous Courseware Upload
Updated: 2026-01-16 00:02:40
API Description
1、通过视频id异步上传课件,支持ppt、pptx及pdf文件格式
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/video/{userid}/uploadPPT/asyn
Request Method
POST
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are subject to rate limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds, 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 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 |
| vid | true | String | Video ID, e.g., 1b448be323dec2a7bed6db61bd7d8a77_1 |
| courseware | true | File | Courseware file, supports ppt, pptx, pdf formats. File size must not exceed 50MB. |
| txt | false | File | Controls which slide of the courseware is displayed at a specific second of the video. The file format is txt and must be UTF-8 encoded; otherwise, chapter titles may appear garbled. |
Example of txt file format, each line: "seconds in video" + ":" + "title"
10:第十秒出现标题
21:第二十秒出现标题
30:第三十秒出现标题
Example
http://api.polyv.net/v2/video/1b448be323/uploadPPT/asyn
Form parameters:
vid=1b448be3239482977934f099f2ceaa0a_1&format=json&sign=F3BAA6F7687AEBEEDACC70F25A79E65D582D1D09&ptime=1617672685886
The courseware file is uploaded to the server as a binary stream via HTTP.
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, provides error details when code is 400 or 500 |
| data | String | Returns "ppt upload successful" on success, empty on failure |
Callback Description
The API only returns the upload result. The courseware conversion result must be obtained via callback. See callback notification usage
Java Request Example
HttpUtil.java and VodSignUtil.java base code can be downloaded locally or obtained online from base code
private static final Logger log = LoggerFactory.getLogger(VodVideoCourseWare.class);
/**
* 异步上传课件
*/
@Test
public void testUploadCourseWareAsync() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userid = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/v2/video/%s/uploadPPT/asyn", userid);
String vid = "1b448be32303e4922a8f70d6b48220ae_1";
String format = "json";
String pptFilePath = getClass().getResource("/file/").getPath() + "Courseware.ppt";
File courseware = new File(pptFilePath);
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("format", format);
Map<String, File> fileMap = new HashMap<>();
fileMap.put("courseware", courseware);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.postFile(url, requestMap, fileMap, Constant.UTF8);
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": "ppt上传成功"
}
Error Example
Returns error JSON
{
"code":400,
"status":"error",
"message":"sign can not be empty.",
"data":""
}
Upload file size must not exceed 50MB
{
"code":400,
"status":"error",
"message":"ppt文件不能超过50M",
"data":""
}
File type error
{
"code":400,
"status":"error",
"message":"文件类型必须为ppt、pptx或pdf",
"data":""
}
Upload is not allowed when the video already has an associated courseware that is being transcoded.
{
"code":400,
"status":"error",
"message":"当前vid关联的课件正在转码中,请稍后再试。",
"data":""
}
