# 上传文件
- 用于上传文件到直书。
# 请求
基本 | |
---|---|
HTTP URL | https://hi-gw.weizhipin.com/open-apis/zhishu/resource/upload |
HTTP Method | POST |
支持的应用 类型 | 自建应用 |
权限要求 开启任一权限即可 | 直书资源上传、导入 |
# 请求头
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
Authorization | string | 是 | user_access_token 值格式:"Bearer access_token "示例值:"Bearer t-7f1bcd13fc57d46bac21793a18e560" |
Content-Type | string | 是 | 固定值:"multipart/form-data; boundary=---7MA4YWxkTrZu0gW" |
# 请求体
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
name | string | 是 | 要上传的文件的名称。 示例值:"直书.pdf" 数据校验规则: 最大长度:250 字符 |
folderVisitCode | string | 是 | 指定上传文件所属的文件夹目录的 visitcode;参数为空字符串时,表示在用户我的文档根目录下创建文件 |
size | long | 是 | 文件大小,单位:字节 |
fileMd5 | string | 是 | 文件内容md5值,用于校验文件是否重复上传 |
file | file | 是 | 文件的二进制内容 |
# cURL示例
curl --location --request POST 'https://hi-gw.weizhipin.com/open-apis/zhishu/resource/upload' \
--header 'Authorization: Bearer t-7f1bcd13fc57d46bac21793a18e560' \
--header 'Content-Type: multipart/form-data' \
--form 'name="demo.pdf"' \
--form 'folderVisitCode="pI3q3Lcgay5"' \
--form 'fileMd5="f9e1c0399e42aeec213710b5f65f296c"' \
--form 'size="1024"' \
--form 'file=@"/path/demo.pdf"'
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 请求体示例
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="name";
demo.pdf
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="folderVisitCode";
pI3q3Lcgay5
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="size";
1024
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="fileMd5";
f9e1c0399e42aeec213710b5f65f296c
---7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file";
Content-Type: application/octet-stream
file binary
---7MA4YWxkTrZu0gW
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 响应
# 响应体
名称 | 类型 | 描述 |
---|---|---|
code | int | 错误码,非 0 表示失败 |
message | string | 错误描述 |
zpData | string | 文件的visitCode |
# 响应体示例
{
"code": 0,
"message": "success",
"data": "JdRBCrTRXsS"
}
1
2
3
4
5
6
2
3
4
5
6