# 同步上传课件

### 接口描述

```
1、通过视频id上传课件，支持ppt、pptx及pdf文件格式
2、接口URL中的{userid}为点播账号userid，具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
```

### 接口URL

```
http://api.polyv.net/v2/video/{userid}/uploadPPT
```

### 请求方式

```
POST
```

### 接口约束

1、接口同时支持HTTP 、HTTPS ，建议使用HTTPS 确保接口安全，接口调用有频率限制，[详细请查看](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/limit/README.md)

2、ppt文件和txt文件必须同时上传

### 请求参数描述

| 参数名    | 必选    | 类型     | 说明                                                                                                                                                                                                        |
| ------ | ----- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| userid | true  | String | 保利威点播账户id，可以参考【[获取密钥](https://git.polyv.net/help-center/document-center/-/blob/master/vod/vod/api/getSecretKey/README.md)】获取,获取路径：官网->登录->点播（API接口）                                                       |
| ptime  | true  | Long   | 当前时间的毫秒级时间戳，3分钟内有效                                                                                                                                                                                        |
| sign   | true  | String | 签名，为40位大写的SHA1值,`生成签名的secretkey密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/vod/api/buildSign/README.md)】 |
| vid    | true  | String | 视频id，例如：1b448be323dec2a7bed6db61bd7d8a77\_1                                                                                                                                                               |
| ppt    | true  | File   | 课件文件，支持ppt、pptx、pdf格式，文件大小不能超过50M                                                                                                                                                                         |
| txt    | true  | File   | 控制视频播放到第几秒时显示课件的某页，文件格式为txt，txt文件必须是UTF-8的编码格式，否则课件的章节标题会显示为乱码                                                                                                                                            |
| format | false | String | <p>返回的数据格式，默认返回json格式<br>xml：返回xml格式<br>json：返回json格式</p>                                                                                                                                                 |

txt文件格式示例如下，每一行为：“视频中的秒数”+“:”+“标题”

```
10:第十秒出现标题
21:第二十秒出现标题
30:第三十秒出现标题
```

### 示例

```requestUrl
http://api.polyv.net/v2/video/1b448be323/uploadPPT
```

表单参数：

```requestUrl
vid=1b448be323fb327a42539cbb788913b4_1&format=json&sign=173B5BBA359A47A8FD00FD671CB87EAE492052BF&ptime=1617332188260
```

课件文件随HTTP二进制流上传至服务器端

### 响应参数描述

| 参数名     | 类型      | 说明                                                                                                                                  |
| ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| code    | Integer | 响应状态码，200为成功返回，非200为失败【详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/vod/api/errorInfo/README.md)】 |
| status  | String  | 响应状态文本信息                                                                                                                            |
| message | String  | 响应描述信息，当code为400或者500的时候，辅助描述错误原因                                                                                                   |
| data    | String  | 响应成功时返回ppt上传成功，响应失败时返回空                                                                                                             |

### Java请求示例

**HttpUtil.java 和 VodSignUtil.java** 基础代码请[点击下载本地](https://git.polyv.net/help-center/document-center/-/blob/master/third_res/util.zip) 或跳转到[基础代码](https://git.polyv.net/help-center/document-center/-/blob/master/vod/vod/api/quickAccess?id=_2系统基础代码/README.md)在线获取

```java
private static final Logger log = LoggerFactory.getLogger(VodVideoCourseWare.class);
/**
 * 同步上传课件
 */
@Test
public void testUploadCourseWareSync() 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",userid);
    String vid =  "1b448be323fb327a42539cbb788913b4_1";
    String format = "json";
    String pptFilePath = getClass().getResource("/file/").getPath() + "class.pptx";
    String pptControlPath = getClass().getResource("/file/").getPath() + "pptControl.txt";
    File ppt = new File(pptFilePath);
    File txt = new File(pptControlPath);

    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("ppt",ppt);
    fileMap.put("txt",txt);
    requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
    
    String response = HttpUtil.postFile(url, requestMap,fileMap,Constant.UTF8);
    log.debug("测试同步上传课件，{}", response);
    //do somethings

}
```

### 响应示例

系统全局错误说明详见[全局错误说明](https://git.polyv.net/help-center/document-center/-/blob/master/vod/vod/api/errorInfo/README.md)

成功示例

```json
{
	"code": 200,
	"status": "success",
	"message": "success",
	"data": "ppt上传成功"
}
```

异常示例

```json
{
	"code": 400,
	"status": "error",
	"message": "sign can not be empty.",
	"data": ""
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://polyv.gitbook.io/document/docs/vod/api/video-management/courseware/upload_courseware_sync.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
