服务端 API/云文档/云空间/素材/上传素材
# 

将云文档或其他Lark套件所需要的素材（图片/文件）上传到云空间。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.larksuite.com/open-apis/drive/v1/medias/upload_all
HTTP Method | POST
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用**<br>开启任一权限即可 | 查看、评论、编辑和管理多维表格(bitable:app)<br>查看、评论、编辑和管理文档(docs:doc)<br>查看、评论、编辑和管理云空间中所有文件(drive:drive)<br>查看、评论、编辑和管理电子表格(sheets:spreadsheet)<br>更新视频会议特效素材(vc:material)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>或<br>`user_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：获取与使用access_token](https://open.larksuite.com/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM)
Content-Type | string | 是 | **示例值**："multipart/form-data; boundary=---7MA4YWxkTrZu0gW"

### 请求体

名称 | 类型 | 必填 | 描述
---|---|---|---
file_name | string | 是 | 文件名<br>**示例值**：""<br>**数据校验规则**：<br>- 最大长度：`250` 字符
parent_type | string | 是 | 上传点类型<br>**示例值**：""<br>**可选值有**：<br>- doc_image：docs图片<br>- docx_image：docx图片<br>- sheet_image：sheet图片<br>- doc_file：doc文件<br>- docx_file：docx文件<br>- sheet_file：sheet文件<br>- vc_virtual_background：vc虚拟背景<br>- bitable_image：bitable图片<br>- bitable_file：bitable文件<br>- moments：同事圈<br>- ccm_import_open：云文档导入文件
parent_node | string | 是 | 上传点的标识符，如：上传点是doc_image，则为"doccn1234556789"<br>**示例值**：""
size | int | 是 | 文件大小,全量上传最大20M<br>**示例值**：<br>**数据校验规则**：<br>- 最大值：`20971520`
checksum | string | 否 | 文件adler32校验和(可选)<br>**示例值**：""
extra | string | 否 | 扩展信息(可选)<br>**示例值**：""
file | file | 是 | 文件内容<br>**示例值**：file binary

### 请求体示例

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

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

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

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

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

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

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

file binary
---7MA4YWxkTrZu0gW
```

## 响应

### 响应体

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

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

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
200 | 1061001 | unknown error. | &nbsp;
400 | 1061002 | params error. | &nbsp;
404 | 1061003 | not found. | &nbsp;
403 | 1061004 | forbidden. | &nbsp;
401 | 1061005 | auth failed. | &nbsp;
200 | 1061006 | internal time out, can retry. | &nbsp;
404 | 1061007 | file has been delete. | &nbsp;
400 | 1061008 | invalid file name. | &nbsp;
400 | 1061021 | upload id expire. | &nbsp;
400 | 1061041 | parent node has been deleted. | &nbsp;
400 | 1061042 | parent node out of limit. | &nbsp;
400 | 1061043 | file size beyond limit. | 请检查文件长度以避免超出限制。[具体限制请参考](https://www.larksuite.com/hc/zh-CN/articles/360049067549)
400 | 1061044 | parent node not exist. | &nbsp;
200 | 1061045 | can retry. | &nbsp;
400 | 1061109 | file name cqc not passed. | &nbsp;
400 | 1061113 | file cqc not passed. | &nbsp;
400 | 1061101 | file quota exceeded. | &nbsp;
202 | 1062004 | cover generating. | &nbsp;
202 | 1062005 | file type not support cover. | &nbsp;
202 | 1062006 | cover no exist. | &nbsp;
400 | 1062007 | upload user not match. | &nbsp;
400 | 1062008 | checksum param Invalid. | &nbsp;
400 | 1062009 | the actual size is inconsistent with the parameter declaration size. | &nbsp;
400 | 1062010 | block missing, please upload all blocks. | &nbsp;
400 | 1062011 | block num out of bounds. | &nbsp;
400 | 1061547 | attachment parent-child relation number exceed. | &nbsp;
400 | 1061061 | user quota exceeded. | &nbsp;
403 | 1061073 | no scope auth. | &nbsp;
400 | 1062012 | file copying. | &nbsp;
400 | 1062013 | file damaged. | &nbsp;
403 | 1062014 | dedupe no support. | &nbsp;
400 | 1062051 | client connect close. | &nbsp;
400 | 1062505 | parent node out of size. | &nbsp;
400 | 1062506 | parent node out of depth. | &nbsp;
400 | 1062507 | parent node out of sibling num. | &nbsp;
400 | 1061101 | file quota exceeded. | &nbsp;
400 | 1061061 | user quota exceeded. | &nbsp;

