# 新东方-获取上传PPT文件token

### 接口URL

```
https://document-2.polyv.net/api/live/user/upload/token
```

### 接口说明

```
1、获取上传PPT文件token
2、接口支持https协议
3、上传文件到OSS参考 https://www.alibabacloud.com/help/zh/doc-detail/31927.htm
```

### 支持格式

```
JSON
```

### 请求方式

```
GET
```

### 请求数限制

```
TRUE
```

### 请求参数

| 参数名      | 必选 | 类型     | 说明                                    |
| -------- | -- | ------ | ------------------------------------- |
| fileId   | 是  | string | 文件ID (文件MD5+userId+type)              |
| userId   | 是  | string | 用户ID                                  |
| type     | 是  | string | PPT类型，“common” 普通ppt ， “animate”动画PPT |
| fileName | 是  | string | 文件名称                                  |

### 响应成功JSON示例：

等待上传

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "encodedCallback": "eyJjYWxsYmFja1VybCI6Imh0dHA6Ly9kb2N1bWVudC0yLnBvbHl2Lm5ldC90ZXN0L2FsaS9vc3MvY2FsbGJhY2svdXBsb2FkIiwiY2FsbGJhY2tIb3N0IjoiZG9jdW1lbnQtMi5wb2x5di5uZXQiLCJjYWxsYmFja0JvZHkiOiJvYmplY3Q9JHtvYmplY3R9JnNpemU9JHtzaXplfSZidWNrZXQ9JHtidWNrZXR9JmV0YWc9JHtldGFnfSZhdXRvSWQ9MTQ5MzcxNyZmaWxlSWQ9ZDg3MDBhODhhZGUxMDUyOTQwMTM3MDM4MTBmY2ZjMTNjZjdmMDdlMDk2YW5pbWF0ZSIsImNhbGxiYWNrQm9keVR5cGUiOiJhcHBsaWNhdGlvbi94LXd3dy1mb3JtLXVybGVuY29kZWQifQ==",
        "signature": "fcrT21oNF7CMxAdI70D20hUu1fE=",
        "autoId": "1493717",
        "dir": "sources/20201028/",
        "bucket": "polyvppt",
        "accessId": "LTAIjy1Mrh8QQcQH",
        "endpoint": "oss-cn-shenzhen.aliyuncs.com",
        "expire": "1603941652",
        "host": "http://polyvppt.oss-cn-shenzhen.aliyuncs.com",
        "callback": "{\"callbackUrl\":\"http://document-2.polyv.net/test/ali/oss/callback/upload\",\"callbackHost\":\"document-2.polyv.net\",\"callbackBody\":\"object=${object}&size=${size}&bucket=${bucket}&etag=${etag}&autoId=1493717&fileId=d8700a88ade105294013703810fcfc13cf7f07e096animate\",\"callbackBodyType\":\"application/x-www-form-urlencoded\"}",
        "convertStatus": "waitUpload",
        "fileId": "d8700a88ade105294013703810fcfc13cf7f07e096animate",
        "object": "sources/20201028/d8700a88ade105294013703810fcfc13cf7f07e096animate.pptx",
        "policy": "eyJleHBpcmF0aW9uIjoiMjAyMC0xMC0yOVQwMzoyMDo1Mi42OTJaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMzIyMTIyNTQ3MjBdLFsic3RhcnRzLXdpdGgiLCIka2V5Iiwic291cmNlcy8yMDIwMTAyOC8iXV19"
    }
}
```

等待转换

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "autoId": "1492485",
        "convertStatus": "waitConvert",
        "fileId": "18947167af136724418f3cfa32343b29cf7f07e096animate"
    }
}
```

转换成功

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": {
        "autoId": "1493717",
        "convertStatus": "normal",
        "fileId": "d8700a88ade105294013703810fcfc13cf7f07e096animate"
    }
}
```

### 响应失败JSON示例：

文件类型错误

```json
{
    "code": 400,
    "status": "error",
    "message": "file type is wrong",
    "data": ""
}
```

### 字段说明

| 参数名                  | 说明                                                                                                                                           |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| code                 | 请求状态响应码                                                                                                                                      |
| status               | 请求状态                                                                                                                                         |
| message              | 错误信息                                                                                                                                         |
| data                 | 请求失败时为空，请求成功为成功信息                                                                                                                            |
| data.autoId          | 记录ID                                                                                                                                         |
| data.fileId          | 文件ID                                                                                                                                         |
| data.convertStatus   | PPT状态，“normal” 正常，不需要重复上传文件，已经有上传成功的相同PPT，可以直接进入轮询。“waitConvert”转换PPT中，已经有相同的文件正在转换中，直接进入轮询。“waitUpload” 等待上传状态，进入上传阿里云步骤。“failConvert” 转换失败 |
| data.accessId        | oss上传OSSAccessKeyId                                                                                                                          |
| data.signature       | oss上传signature                                                                                                                               |
| data.policy          | oss上传policy                                                                                                                                  |
| data.endpoint        | oss上传的endpoint                                                                                                                               |
| data.encodedCallback | oss上传的回调参数BASE64编码                                                                                                                           |
| data.callback        | oss上传的回调参数                                                                                                                                   |
| data.object          | oss上传文档key                                                                                                                                   |
| data.host            | oss上传地址                                                                                                                                      |
| data.bucket          | oss上传桶                                                                                                                                       |
| data.expire          | oss上传有效时间                                                                                                                                    |
| data.dir             | 上传到oss的文件夹                                                                                                                                   |

### java请求示例

```java
public static void test() {
        String url = "https://document-2.polyv.net/api/live/user/upload/token";

        Map<String, String> params = new HashMap<>();
        params.put("fileId", "d8700a88ade105294013703810fcfc13cf7f07e096animate");
		params.put("type", "animate");
		params.put("fileName", "animate.pptx");
		params.put("userId", "cf7f07e096");
        // 调用Polyv的httpClient工具类发送请求
        String content = HttpClientUtil.getInstance().sendHttpPost(url, params);
        System.out.println(content);
    }
```


---

# 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/unclassified/2020/3ff709e09ac8959a2a67fa1c2d6d59c4.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.
