# 分片上传素材-上传分片

根据 [预上传](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/media/upload_prepare)接口返回的上传事务 ID 和分片策略上传对应的素材分片。上传完成后，你可调用 [分片上传素材（完成上传）](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/media/upload_finish)触发完成上传。

## 使用限制

该接口调用频率上限为 5 QPS，10000 次/天。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/drive/v1/medias/upload_part
HTTP Method | POST
接口频率限制 | [特殊频控](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用**<br>开启任一权限即可 | 查看、评论、编辑和管理多维表格(bitable:app)<br>查看、评论、编辑和管理文档(docs:doc)<br>上传图片和附件到云文档中(docs:document.media:upload)<br>查看、评论、编辑和管理云空间中所有文件(drive:drive)<br>查看、评论、编辑和管理电子表格(sheets:spreadsheet)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>或<br>`user_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | 是 | **示例值**："multipart/form-data; boundary=---7MA4YWxkTrZu0gW"

更多云文档接口权限问题，参考[常见问题](https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN)。

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
upload_id | string | 是 | 分片上传事务的 ID。通过调用[分片上传素材（预上传）](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/drive-v1/media/upload_prepare)接口获取。<br>**示例值**："7111211691345512356"
seq | int | 是 | 块号，从 0 开始计数。<br>**示例值**：0
size | int | 是 | 块的大小，单位为字节。<br>**示例值**：4194304
checksum | string | 否 | 素材文件的 Adler-32 校验和<br>**示例值**："3248270248"
file | file | 是 | 素材文件分片的二进制内容<br>**示例值**：file binary

### 请求体示例

```HTTP
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="upload_id";

7111211691345512356
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="seq";

0
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="size";

4194304
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="checksum";

3248270248
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file";
Content-Type: application/octet-stream

file binary
---7MA4YWxkTrZu0gW
```

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
200 | 1061001 | internal error. | 服务内部错误，包括超时，错误码没处理。
400 | 1061002 | params error. | 请检查请求参数是否正确。
404 | 1061003 | not found. | 请确认对应资源是否存在。
403 | 1061004 | forbidden. | 请确认当前身份是否有对应上传节点的的权限，如用户是否有上传到指定doc的编辑权限。
401 | 1061005 | auth failed. | 请使用正确身份访问该接口。
200 | 1061006 | internal time out. | 服务内部超时，可稍后再试。
404 | 1061007 | file has been delete. | 请确认对应节点未被删除。
400 | 1061008 | invalid file name. | 请检查文件名，当前文件名过长或者为空。
400 | 1061021 | upload id expire. | 上传事务过期，请重头开始上传。
400 | 1061041 | parent node has been deleted. | 请确认上传点未被删除。
400 | 1061042 | parent node out of limit. | 在当前上传点上传过多素材，请更换上传点。
400 | 1061043 | file size beyond limit. | 请检查文件长度以避免超出限制。具体限制请参考[飞书帮助中心](https://www.feishu.cn/hc/zh-CN/articles/360049067549)。
400 | 1061044 | parent node not exist. | 请确认上传点是否存在。
200 | 1061045 | can retry. | 内部可重试错误，请稍后重试。
400 | 1061109 | file name cqc not passed. | 请确保上传的文件和文件名合规。
400 | 1061113 | file cqc not passed. | 请确保上传的文件和文件名合规。
400 | 1061101 | file quota exceeded. | 租户容量超限，请确保租户有足够容量进行上传。
202 | 1062004 | cover generating. | 缩略图正在生成中，请稍后再试。
202 | 1062005 | file type not support cover. | 此文件类型不支持生成缩略图。
202 | 1062006 | cover no exist. | 缩略图正在生成中，请稍后再试。
400 | 1062007 | upload user not match. | 请确保当前请求身份和上传任务的身份为同一个。
400 | 1062008 | checksum param Invalid. | 请确保文件/文件块的checksum正确。
400 | 1062009 | the actual size is inconsistent with the parameter declaration size. | 实际传输的文件大小和参数说明的大小不符合一致。
400 | 1062010 | block missing, please upload all blocks. | 部分文件分片缺失，请确保所有文件分片上传完成。
400 | 1062011 | block num out of bounds. | 上传过多文件分片，请确保上传的为对应文件。
400 | 1061547 | attachment parent-child relation number exceed. | 特指上传到文档的素材超出限制。
400 | 1061061 | user quota exceeded. | 个人容量超限，请确保个人有足够容量进行上传。
403 | 1061073 | no scope auth. | 没有申请接口权限。
400 | 1062012 | file copying. | 文件正在拷贝中。
400 | 1062013 | file damaged. | 文件拷贝失败。
403 | 1062014 | dedupe no support. | 不允许秒传。
400 | 1062051 | client connect close. | 客户端断开连接。
400 | 1062505 | parent node out of size. | 云空间中所有层级的节点总和超限。上限为 40 万个，请检查节点数量。了解更多，参考[云空间概述](https://open.feishu.cn/document/ukTMukTMukTM/uUDN04SN0QjL1QDN/files/guide/introduction)。
400 | 1062506 | parent node out of depth. | 云空间目录深度超限制（15限制）。
400 | 1062507 | parent node out of sibling num. | 云空间中根目录或文件夹的单层节点超限。上限为 1500 个，你可通过将文件新建到不同文件夹中解决。

