上传
把文件传给我们:每个文件直接上传到存储,5 GB 以内可一次发送,也可分片上传。完整流程请参阅上传文件。
本页内容
POST/v1/uploads
为每个文件发起一个上传,并返回各自的前几个分片链接。5 GB 以内的文件会得到一个用于整个文件的链接:使用 PUT 通过一次请求发送。更大的文件,或 multipart 为 true 时的任意文件,需要分片发送:使用 PUT 将每个分片的原始字节发送到其 url。除最后一个分片外,每个分片均为 part_size 字节。然后调用完成上传。文件大小和类型会在此时、即发送任何内容之前接受检查;文件内容则在上传完成时检测。
请求头
Idempotency-Keystring任意唯一文本,例如 UUID。重试同一请求时,每次都原样再次发送。保留 24 小时。
最多 255 个字符
请求体
operationstring必填文件要用于的操作。它决定允许的文件类型和大小。
filesobject[]必填1 至 50 项
files[].namestring必填文件名,包含扩展名。
files[].sizeinteger必填文件大小,以字节为单位。
最小值:1
files[].typestring文件的媒体类型,例如
video/mp4(如已知)。multipartboolean无论文件大小,都分片发送。不设置此项时,5 GB 以内的文件会得到一个用于整个文件的链接。
默认值:
false
返回
- 201上传列表,每个上传附带其前几个分片链接。
11 个字段
filesobject[]必填files[].idstring必填files[].namestring必填去除了不安全字符的文件名。
files[].sizeinteger必填files[].part_sizeinteger必填除最后一个分片外每个分片的大小;通过一次请求发送时,即为文件大小。
files[].part_countinteger必填最小值:1
files[].partsobject[]必填前几个分片的链接。其余链接请通过
POST /v1/uploads/{id}/parts获取。files[].parts[].numberinteger必填最小值:1
files[].parts[].urlstring (URL)必填使用
PUT将分片的字节发送到此处。链接有效期为一小时。files[].links_expire_atstring (date-time)必填files[].delete_atstring (date-time)必填没有作业使用该文件时,文件的删除时间。
错误
示例
curl -X POST https://api.filesokay.com/v1/uploads \
-H "Authorization: Bearer $FILESOKAY_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"operation": "video.compress",
"files": [
{
"name": "lecture.mp4",
"size": 12417467,
"type": "video/mp4"
}
]
}'const res = await fetch("https://api.filesokay.com/v1/uploads", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
operation: "video.compress",
files: [
{
name: "lecture.mp4",
size: 12417467,
type: "video/mp4"
}
]
}),
});
const uploads = await res.json();import os
import uuid
import requests
res = requests.post(
"https://api.filesokay.com/v1/uploads",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"operation": "video.compress",
"files": [
{
"name": "lecture.mp4",
"size": 12417467,
"type": "video/mp4"
}
]
},
)
uploads = res.json(){
"files": [
{
"id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4",
"size": 12417467,
"part_size": 12417467,
"part_count": 1,
"parts": [
{
"number": 1,
"url": "https://…"
}
],
"links_expire_at": "2026-12-03T10:22:53Z",
"delete_at": "2026-12-10T09:22:52Z"
}
]
}GET/v1/uploads/{id}
返回存储已收到的分片,这样中断的上传只需发送缺失的分片。上传完成后,响应为该文件。
路径参数
idstring必填
返回
- 200上传进度;上传完成后则为该文件。
UploadProgress · 9 个字段
idstring必填statestring必填sizeinteger必填part_sizeinteger必填part_countinteger必填parts_receivedobject[]必填parts_received[].numberinteger必填parts_received[].sizeinteger必填delete_atstring (date-time)必填
File · 18 个字段
idstring必填namestring必填operationstring必填上传该文件所针对的操作。
statestring必填可选值:
uploading或uploadedsizeinteger必填created_atstring (date-time)必填uploaded_atstring (date-time)delete_atstring (date-time)删除时间。有作业正在使用该文件时不返回此字段。
checkobject上传完成时对文件内容的检测结果。
check.statestring必填proceed:操作可以使用该文件。refuse:无法使用,原因见reason。couldnt_read:检测未能读取全部内容;作业会完整读取。check_failed:我们这边出现问题;再次完成上传即可重试。可选值:
checking、proceed、refuse、couldnt_read或check_failedcheck.reasonstringcheck.detailobjectcheck.kindstring文件的真实类别,例如
video。check.typestring文件的真实格式,例如
mp4,与文件名无关。check.factsobject检测读取到的信息,例如视频的时长、大小和编解码器。
check.facts_completebooleandownload_urlstring (URL)文件上传完成后,仅在
GET /v1/files/{id}中返回。download_expires_atstring (date-time)
错误
示例
curl https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c", {
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
const progress = await res.json();import os
import requests
res = requests.get(
"https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
progress = res.json(){
"delete_at": "2026-12-10T09:22:52Z",
"id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"part_count": 1,
"part_size": 12417467,
"parts_received": [
{
"number": 1,
"size": 12417467
}
],
"size": 12417467,
"state": "uploading"
}DELETE/v1/uploads/{id}
取消上传,并丢弃已发送的分片。
路径参数
idstring必填
返回
- 204已取消。
错误
示例
curl -X DELETE https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
console.log(res.status);import os
import requests
res = requests.delete(
"https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
print(res.status_code)POST/v1/uploads/{id}/parts
一次最多获取 100 个分片的链接,适用于大文件或链接已过期的情况。
路径参数
idstring必填
请求体
part_numbersinteger[]必填1 至 100 项
返回
- 200链接列表。
4 个字段
partsobject[]必填parts[].numberinteger必填最小值:1
parts[].urlstring (URL)必填使用
PUT将分片的字节发送到此处。链接有效期为一小时。links_expire_atstring (date-time)必填
错误
示例
curl -X POST https://api.filesokay.com/v1/uploads/file_20f80f7404ff41858dc0a0544f059576/parts \
-H "Authorization: Bearer $FILESOKAY_KEY" \
-H "Content-Type: application/json" \
-d '{
"part_numbers": [
21,
22,
23
]
}'const res = await fetch("https://api.filesokay.com/v1/uploads/file_20f80f7404ff41858dc0a0544f059576/parts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
part_numbers: [
21,
22,
23
]
}),
});
const links = await res.json();import os
import requests
res = requests.post(
"https://api.filesokay.com/v1/uploads/file_20f80f7404ff41858dc0a0544f059576/parts",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
json={
"part_numbers": [
21,
22,
23
]
},
)
links = res.json(){
"links_expire_at": "2026-12-03T19:00:33Z",
"parts": [
{
"number": 21,
"url": "https://…"
},
{
"number": 22,
"url": "https://…"
},
{
"number": 23,
"url": "https://…"
}
]
}POST/v1/uploads/{id}/complete
合并各分片并检测文件内容。响应为该文件及其检测结果:proceed 表示操作可以使用该文件。重复调用会得到相同的响应。缺失或长度不对的分片会在 409 响应中列出。
路径参数
idstring必填
返回
- 200文件及其检测结果。
18 个字段
idstring必填namestring必填operationstring必填上传该文件所针对的操作。
statestring必填可选值:
uploading或uploadedsizeinteger必填created_atstring (date-time)必填uploaded_atstring (date-time)delete_atstring (date-time)删除时间。有作业正在使用该文件时不返回此字段。
checkobject上传完成时对文件内容的检测结果。
check.statestring必填proceed:操作可以使用该文件。refuse:无法使用,原因见reason。couldnt_read:检测未能读取全部内容;作业会完整读取。check_failed:我们这边出现问题;再次完成上传即可重试。可选值:
checking、proceed、refuse、couldnt_read或check_failedcheck.reasonstringcheck.detailobjectcheck.kindstring文件的真实类别,例如
video。check.typestring文件的真实格式,例如
mp4,与文件名无关。check.factsobject检测读取到的信息,例如视频的时长、大小和编解码器。
check.facts_completebooleandownload_urlstring (URL)文件上传完成后,仅在
GET /v1/files/{id}中返回。download_expires_atstring (date-time)
错误
示例
curl -X POST https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c/complete \
-H "Authorization: Bearer $FILESOKAY_KEY"const res = await fetch("https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c/complete", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
},
});
const file = await res.json();import os
import requests
res = requests.post(
"https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c/complete",
headers={
"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
},
)
file = res.json(){
"id": "file_3cf0737aefa34b89b7b4443c9467d60c",
"name": "lecture.mp4",
"operation": "video.compress",
"state": "uploaded",
"size": 12417467,
"created_at": "2026-12-03T09:22:53Z",
"uploaded_at": "2026-12-03T09:23:02Z",
"delete_at": "2026-12-04T09:23:02Z",
"check": {
"state": "proceed",
"kind": "video",
"type": "mp4",
"facts": {
"container": "mp4",
"protection": "none",
"attachments": [],
"duration_ms": 20023,
"frame_count": 600,
"audio_tracks": [
{
"codec": "aac",
"channels": 1,
"sample_rate": 44100
}
],
"video_tracks": [
{
"hdr": "none",
"codec": "h264",
"width": 1280,
"chroma": "420",
"height": 720,
"profile": "High",
"rotation": 0,
"bit_depth": 8,
"frame_rate": 30,
"interlaced": false,
"variable_frame_rate": false
}
],
"data_end_bytes": 12417467,
"subtitle_tracks": []
},
"facts_complete": true
}
}