上傳檔案

POST /api/v1/uploads — 取得簽章 URL,用 PUT 上傳本機影片檔案(MP4、MOV 或 WebM,最大 100MB),再把回傳的 video_url 交給 /upscale 進行畫質提升。上傳 URL 有效期為 1 小時,不需要附帶 API 金鑰,網址本身就是上傳權限。

如果你的影片沒有公開的 URL,請先上傳。上傳需要兩個請求:先向我們取得簽章上傳 URL,再用 PUT 把檔案直接傳到儲存空間。

POST https://videoupscaler.co/api/v1/uploads

請求

欄位型別必填說明
content_typestring是video/mp4、video/quicktime 或 video/webm
sizeinteger是檔案大小(位元組),最大 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 本身就是授權憑證。
headersPUT 時要一併送出的標頭。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 天後可能會被刪除。

錯誤

狀態碼錯誤碼發生時機
400invalid_request不支援的 content_type、無效的 size,或 PUT 送出的 Content-Type 不一致、上傳中斷
403paid_plan_required帳號從未購買點數或訂閱
402insufficient_credits你的點數餘額為 0
403invalid_upload_token上傳 URL 無效或已過期(PUT)
411invalid_requestPUT 沒有請求本文或缺少 Content-Length
413file_too_large檔案超過 100MB,或大於宣告的 size