接口文档

  • 为非实时能力提供文件上传功能

1.上传文件

  • 请求URL

    https://upload-ost-api.xfyun.cn/file/upload
    
  • 请求方式

    POST
    
  • Accept

    application/json
    
  • Content-Type

    multipart/form-data
    
  • 请求参数

    content-type: multipart/form-data; boundary=--------------------------856841733413091254401013
    content-length: 448
    Connection: keep-alive
    
    ----------------------------856841733413091254401013
    Content-Disposition: form-data; name="app_id"
    
    afadfq3
    ----------------------------856841733413091254401013
    Content-Disposition: form-data; name="data"; filename="test.txt"
    Content-Type: text/plain
    
    ==test==
    ----------------------------856841733413091254401013
    Content-Disposition: form-data; name="request_id"
    
    202007030859
    ----------------------------856841733413091254401013--
    
  • 请求参数说明

    | 参数名 | 类型 | 是否必传 | 描述 | | :--------: | :----: | :------: | :---------------------: | | request_id | string | 是 | 请求唯一标识 | | app_id | string | 是 | 应用唯一标识 | | cloud_id | string | 否 | 云唯一标识(0代表公有云) | | data | file | 是 | 文件上传数据 |

  • 返回参数

    {
        "code": 0,
        "sid": "ost00010002@dx172fd79467d7a04802",
        "data": {
            "url": "xxxxxxx"
        },
        "message": "success"
    }
    
  • 返回参数说明

    | 参数名 | 类型 | 描述 | | :-----: | :----: | :---------------: | | code | int | 错误码,0标识成功 | | message | string | 错误描述 | | sid | string | 会话唯一标识 | | url | string | 文件下载地址 |

2.分块上传

分片数量:1~10,000

每块文件大小在:5M~5G,最后一块大小可以小于5M

2.1.初始化分块信息

  • 请求URL

    https://upload-ost-api.xfyun.cn/file/mpupload/init
    
  • 请求方式

    POST
    
  • Accept

    application/json
    
  • Content-Type

    application/json
    
  • 请求参数

    {
        "request_id":"202006290840",
        "app_id":"4CC5779A",
        "cloud_id":"0"
    }
    
  • 请求参数说明

    | 参数名 | 类型 | 是否必传 | 描述 | | :--------: | :----: | :------: | :---------------------: | | app_id | string | 是 | 用户唯一标识 | | request_id | string | 是 | 请求唯一标识 | | cloud_id | string | 否 | 云唯一标识(0代表公有云) |

  • 返回参数

    {
        "code": 0,
        "sid": "ost00010004@dx172fd871c417a04802",
        "data": {
            "upload_id": "up_200629084309761716841002"
        },
        "message": "success"
    }
    
  • 返回参数说明

    | 参数名 | 类型 | 描述 | | :-------: | :----: | :---------------: | | code | int | 错误码,0标识成功 | | message | string | 错误描述 | | sid | string | 会话唯一标识 | | upload_id | string | 上传唯一标识 |

2.2.分块上传

  • 请求URL

    https://upload-ost-api.xfyun.cn/file/mpupload/upload
    
  • 请求方式

    POST
    
  • Accept

    application/json
    
  • Content-Type

    multipart/form-data
    
  • 请求参数

    content-type: multipart/form-data; boundary=--------------------------061214608996181387989480
    content-length: 691
    Connection: keep-alive
    
    ----------------------------061214608996181387989480
    Content-Disposition: form-data; name="app_id"
    
    afadfq3
    ----------------------------061214608996181387989480
    Content-Disposition: form-data; name="slice_id"
    
    1
    ----------------------------061214608996181387989480
    Content-Disposition: form-data; name="data"; filename="test.txt"
    Content-Type: text/plain
    
    ==test==
    ----------------------------061214608996181387989480
    Content-Disposition: form-data; name="upload_id"
    
    up_200703101613360646021006
    ----------------------------061214608996181387989480
    Content-Disposition: form-data; name="request_id"
    
    202007031016
    ----------------------------061214608996181387989480--
    
  • 请求参数说明

    | 参数名 | 类型 | 是否必传 | 描述 | | :--------: | :----: | :------: | :----------: | | request_id | string | 是 | 请求唯一标识 | | app_id | string | 是 | 应用唯一标识 | | upload_id | string | 是 | 上传唯一标识 | | slice_id | int | 是 | 分片号 | | data | file | 是 | 上传数据 |

  • 返回参数

    {
        "code": 0,
        "sid": "ost00010006@dx172fd8b7afb7a04802",
        "message": "success"
    }
    
  • 返回参数说明

    | 参数名 | 类型 | 描述 | | :-----: | :----: | :---------------: | | code | int | 错误码,0标识成功 | | sid | string | 会话唯一标识 | | message | string | 错误描述 |

2.3.分块上传完成

  • 请求URL

    https://upload-ost-api.xfyun.cn/file/mpupload/complete
    
  • 请求方式

    POST
    
  • Accept

    application/json
    
  • Content-Type

    application/json
    
  • 请求参数

    {
        "request_id":"202006290849",
        "app_id": "4CC5779A",
        "upload_id": "up_200629084309761716841002",
    }
    
  • 请求参数说明

    | 参数名 | 类型 | 是否必传 | 描述 | | :--------: | :----: | :------: | :----------: | | request_id | string | 是 | 请求唯一标识 | | app_id | string | 是 | 应用唯一标识 | | upload_id | string | 是 | 上传唯一标识 |

  • 返回参数

    {
        "code": 0,
        "sid": "ost00010008@dx172fd8fda817a04802",
        "data": {
            "url": "xxx"
        },
        "message": "success"
    }
    
  • 返回参数说明

    | 参数名 | 类型 | 描述 | | :-----: | :----: | :---------------: | | code | int | 错误码,0标识成功 | | sid | string | 会话唯一标识 | | url | string | 文件下载地址 | | message | string | 错误描述 |

2.4.取消分块上传

  • 请求URL

    https://upload-ost-api.xfyun.cn/file/mpupload/cancel
    
  • 请求方式

    POST
    
  • Accept

    application/json
    
  • Content-Type

    application/json
    
  • 请求参数

    {
        "request_id":"202006290856",
        "app_id":"4CC5779A",
        "upload_id":"up_200622190707122850851003"
    }
    
  • 请求参数说明

    | 参数名 | 类型 | 是否必传 | 描述 | | :--------: | :----: | :------: | :----------: | | request_id | string | 是 | 请求唯一标识 | | app_id | string | 是 | 应用唯一标识 | | upload_id | string | 是 | 上传唯一标识 |

  • 返回参数

    {
        "code": 0,
        "sid": "ost0001000c@dx172fd94a7f97a04802",
        "message": "success"
    }
    
  • 返回参数说明

    | 参数名 | 类型 | 描述 | | :-----: | :----: | :---------------: | | code | int | 错误码,0标识成功 | | sid | string | 会话唯一标识 | | message | string | 错误描述 |

4.错误码

错误码 错误描述 处理方式
10001 请求参数不正确 检查请求参数是否合法
10002 操作s3出错 提交工单
10003 操作数据库出错 提交工单
10004 操作缓存出错 提交工单
10005 上传信息已过期或没有上传 确认请求唯一标识是否已过期
10006 io操作失败 提交工单
10007 推送任务失败 提交工单

results matching ""

    No results matching ""