上传文件
POST /api/v1/uploads — 获取签名 URL,用 PUT 上传本地视频文件,然后进行画质增强。
如果你的视频没有公开 URL,请先上传。上传分两步:先向我们申请一个签名上传 URL,再用 PUT 把文件直接传到存储。
POST https://videoupscaler.co/api/v1/uploads请求
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
content_type | string | 是 | video/mp4、video/quicktime 或 video/webm |
size | integer | 是 | 文件大小(字节),不超过 100MB(104857600) |
超过 100MB 的文件,请自行托管,并把 URL 传给 /upscale(最大 500MB)。
响应
返回 201 Created:
{
"upload_url": "https://api.videoupscaler.co/uploads/eyJrZXki…",
"method": "PUT",
"headers": { "Content-Type": "video/mp4" },
"video_url": "https://storage.videoupscaler.co/videos/api/5f0c…mp4",
"max_bytes": 7340032,
"expires_at": "2026-09-30T09:00:00.000Z"
}| 字段 | 说明 |
|---|---|
upload_url | 用 PUT 上传文件的地址。无需 Authorization 请求头,URL 本身即代表授权。 |
headers | PUT 时需携带的请求头。Content-Type 必须与你声明的一致。 |
video_url | 上传完成后,把它传给 /upscale。 |
max_bytes | 如果文件大于你声明的 size,上传会被拒绝。 |
expires_at | 上传 URL 的有效期为 1 小时。 |
完整示例
FILE=clip.mp4
SIZE=$(wc -c < "$FILE" | tr -d ' ')
# 1. Get an upload URL
UPLOAD=$(curl -s https://videoupscaler.co/api/v1/uploads \
-H "Authorization: Bearer $VIDEOUPSCALER_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"content_type\": \"video/mp4\", \"size\": $SIZE}")
# 2. Upload the file
curl -X PUT "$(echo "$UPLOAD" | jq -r .upload_url)" \
-H "Content-Type: video/mp4" \
--data-binary @"$FILE"
# 3. Upscale it
curl https://videoupscaler.co/api/v1/upscale \
-H "Authorization: Bearer $VIDEOUPSCALER_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"video_url\": \"$(echo "$UPLOAD" | jq -r .video_url)\", \"resolution\": \"1080p\"}"import { readFile } from 'node:fs/promises';
const api = 'https://videoupscaler.co/api/v1';
const auth = { Authorization: `Bearer ${process.env.VIDEOUPSCALER_API_KEY}` };
const file = await readFile('clip.mp4');
// 1. Get an upload URL
const upload = await fetch(`${api}/uploads`, {
method: 'POST',
headers: { ...auth, 'Content-Type': 'application/json' },
body: JSON.stringify({ content_type: 'video/mp4', size: file.length }),
}).then((r) => r.json());
// 2. Upload the file
await fetch(upload.upload_url, { method: 'PUT', headers: upload.headers, body: file });
// 3. Upscale it
const task = await fetch(`${api}/upscale`, {
method: 'POST',
headers: { ...auth, 'Content-Type': 'application/json' },
body: JSON.stringify({ video_url: upload.video_url, resolution: '1080p' }),
}).then((r) => r.json());import os, requests
api = "https://videoupscaler.co/api/v1"
auth = {"Authorization": f"Bearer {os.environ['VIDEOUPSCALER_API_KEY']}"}
path = "clip.mp4"
# 1. Get an upload URL
upload = requests.post(f"{api}/uploads", headers=auth,
json={"content_type": "video/mp4", "size": os.path.getsize(path)}).json()
# 2. Upload the file
with open(path, "rb") as f:
requests.put(upload["upload_url"], headers=upload["headers"], data=f).raise_for_status()
# 3. Upscale it
task = requests.post(f"{api}/upscale", headers=auth,
json={"video_url": upload["video_url"], "resolution": "1080p"}).json()PUT 成功时返回 200 和 {"video_url": "…"}。
注意事项
- 申请上传 URL 不收费,但账号积分余额至少需要 1 积分。
- 上传的文件仅用于处理,可能会在 7 天后被删除。
错误
| 状态码 | 错误码 | 触发条件 |
|---|---|---|
400 | invalid_request | 不支持的 content_type、无效的 size,或 PUT 发送的 Content-Type 与声明不一致、上传中断 |
403 | paid_plan_required | 账号从未购买过积分或订阅 |
402 | insufficient_credits | 积分余额为零 |
403 | invalid_upload_token | 上传 URL 无效或已过期(PUT) |
411 | invalid_request | PUT 没有请求体或缺少 Content-Length |
413 | file_too_large | 文件超过 100MB,或大于声明的 size |