// ticket is data from a successful presign response; file is the original File.
const uploaded = await fetch(ticket.upload_url, {
method: ticket.upload_method,
headers: ticket.upload_headers,
body: file,
credentials: "omit",
});
if (!uploaded.ok) throw new Error("Direct upload failed");
// Call the authenticated confirm endpoint only after this succeeds.
{
"success": false,
"code": 501,
"msg": "当前存储后端不支持直传,请改用 /upload/stream"
}
// ticket is data from a successful presign response; file is the original File.
const uploaded = await fetch(ticket.upload_url, {
method: ticket.upload_method,
headers: ticket.upload_headers,
body: file,
credentials: "omit",
});
if (!uploaded.ok) throw new Error("Direct upload failed");
// Call the authenticated confirm endpoint only after this succeeds.
{
"success": false,
"code": 501,
"msg": "当前存储后端不支持直传,请改用 /upload/stream"
}
File management
Upload File Stream
POST /api/v1/files/upload/stream · Upload local files via multipart/form-data to R2
// ticket is data from a successful presign response; file is the original File.
const uploaded = await fetch(ticket.upload_url, {
method: ticket.upload_method,
headers: ticket.upload_headers,
body: file,
credentials: "omit",
});
if (!uploaded.ok) throw new Error("Direct upload failed");
// Call the authenticated confirm endpoint only after this succeeds.
{
"success": false,
"code": 501,
"msg": "当前存储后端不支持直传,请改用 /upload/stream"
}
POST
/
api
/
v1
/
files
/
upload
/
stream
// ticket is data from a successful presign response; file is the original File.
const uploaded = await fetch(ticket.upload_url, {
method: ticket.upload_method,
headers: ticket.upload_headers,
body: file,
credentials: "omit",
});
if (!uploaded.ok) throw new Error("Direct upload failed");
// Call the authenticated confirm endpoint only after this succeeds.
{
"success": false,
"code": 501,
"msg": "当前存储后端不支持直传,请改用 /upload/stream"
}
- Upload local files or raw binary data via
multipart/form-data- MP4/MOV video: up to 200 MiB (209,715,200 bytes); other files: 100 MiB (104,857,600 bytes)
- Files automatically expire and are purged after 72 hours
- Limit of 2,000 active files per user; returns 429 when quota is exhausted
- Auth:
Authorization: Bearer sk-...
Browser direct upload
Browser direct uploads are live as of October 12, 2026. The multipart endpoint remains available.
POST /api/v1/files/upload/presign and POST /api/v1/files/upload/confirm endpoints (also available under /v1/files/upload/*), not the publishing media-presign endpoint. Ticket and confirmation calls use the existing file-upload authentication. Both accept JSON: presign requires non-empty string file_name and mime_type, a positive integer file_size, and optional string upload_path; confirm requires string file_id and the same integer file_size. The standard response uses success (boolean), code (integer), msg (string), and data on success. Ticket data contains file_id, upload_url, upload_method, upload_headers (a string-to-string map), resource_url, download_url, and expires_at.
Upload tickets default to 15 minutes and cannot exceed 1 hour. Ticket data.expires_at is the upload deadline, not the confirmed file’s retention deadline.
- Request a ticket with
file_name,mime_type, positivefile_sizein bytes, and optionalupload_path. The ceiling is 200 MiB (209,715,200 bytes) for MP4/MOV video and 100 MiB (104,857,600 bytes) for other files; a website flow may impose a lower limit. For ordinary uploads, a video MIME type or.mp4/.movfilename selects the video reading budget, but files larger than 100 MiB must also pass actual MP4/MOV container checks. Renaming a non-video file does not raise its valid limit. The reference-video browser-check purpose below has a separate policy. Base64 uploads retain the 100 MiB decoded-file limit. - PUT the original browser
Fileas the request body todata.upload_url, usingdata.upload_methodand every returneddata.upload_headersvalue unchanged. These are the required signed headers, includingIf-None-Match: *, which prevents replay from overwriting an existing object. Do not wrap the file inFormData, use the site’s authenticated client, or add an OmniMux Bearer header. Setcredentials: "omit". - After PUT succeeds, confirm with
file_idand the samefile_size. Use the confirmed URL and retention in the existing upload library only after confirmation succeeds. A ticket’sresource_urlis not proof of a confirmed file.
msg.
Confirmation checks object existence, positive size, and stored Content-Type metadata through R2 HEAD, without reading the complete object body. Actual size must equal the original ticket declaration, even if confirmation supplies a different size; type metadata must equal the ticket’s normalized MIME type. Confirmation atomically activates only an owned, pending, unexpired record. Repeated or conflicting confirmation cannot replace an active object. For ordinary video uploads above 100 MiB, confirmation also reads the object to verify the complete stored size and an MP4/MOV container; a temporary read failure can be retried. This container check does not establish codec or decodability. These metadata checks do not validate the actual media format, duration, or safety. Separate reference-media preparation still applies to ordinary uploads; the reference-video purpose below uses browser checks instead.
Reference-video browser checks
The reference-video browser-check purpose is available as of October 18, 2026. The influencer page reads and checks the original file in the browser before requesting an upload. Failed checks or unsupported source-following duration/framing produce the existing top-of-page message and prevent adding or uploading that file. The browser retains the complete metadata and submits it again for generation; duration and framing follow the reference rather than manual controls. Presign accepts the following additional JSON fields. Multipart fallback accepts the same fields as form values;video_metadata must be a JSON-encoded string in multipart, rather than another file part.
| Field | Type in presign JSON | Required | Description |
|---|---|---|---|
purpose | string | No | Use exactly influencer_reference_video only after the full local reference-video checks pass. Omit for ordinary uploads. |
video_metadata | object | With this purpose | The raw browser-read fields below, without a raw, version, or browserMetadata wrapper. Missing or out-of-range declarations are rejected. These are client declarations, not server-verified media facts. |
video_metadata field | Type | Description |
|---|---|---|
duration | number | Actual container duration in seconds; retain the measured fractional value. |
video_duration | number | Actual video-track duration in seconds; retain the measured fractional value. |
width | integer | Actual display width in pixels, including rotation. |
height | integer | Actual display height in pixels, including rotation. |
frame_rate | number | Measured video frames per second. |
video_codec | string | h264 or hevc. |
audio_codec | string | Empty for no audio; otherwise aac, mp3, or pcm / pcm_* for MOV only. |
container | string | Actual container: mp4 or mov. |
size_bytes | integer | Actual positive file size in bytes; must match the upload’s declared size. |
| Declared specification | Current requirement |
|---|---|
| Container and video-track duration | Both are from 4 through 30 seconds and follow the whole-second rules below. No extra tolerance applies to these bounds. |
| Width and height | Each is 300–6000 pixels. |
| Total pixels | width × height is 407696–8295044. |
| Input width-to-height ratio | 0.4–2.5, plus the stricter source-following framing rule below. |
| Frame rate | 24–60 frames per second. |
| Source-following framing | This purpose is checked against the current 480p framing set: 16:9, 9:16, or 3:4. For n:d, whole-pixel rounding is accepted only when abs(width × d - height × n) ≤ (n + d) / 2. The page additionally checks the selected output resolution; 720p currently supports only 16:9 and 9:16. A valid reference such as 1:1 is rejected for this purpose because the current service cannot preserve its framing. |
Duration following and audio/video tail differences
Lets = round(video_duration) and T = 1 / frame_rate + 0.001 seconds. The actual generation duration s must be 4–30 seconds, and both conditions must hold:
- The video-track duration is within
Tofs:abs(video_duration - s) ≤ T. - The container satisfies
abs(duration - s) ≤ T. Otherwise, accept it only with a supported audio track from the table above,duration ≥ video_duration, andduration - video_duration ≤ T.
container: video/mp4 for MP4; video/quicktime or video/x-quicktime for MOV. In presign, file_size must equal video_metadata.size_bytes; in multipart, the file part’s size and Content-Type must match those declarations. The 200 MiB (209,715,200-byte) hard ceiling still applies. The service checks declaration bounds and consistency but does not read the file to establish media facts for this purpose.
The server binds this policy to the upload record when presign succeeds; it retains the reserved influencer-reference/browser-upload path and ignores a caller-supplied custom folder for this purpose. Confirmation cannot change an ordinary ticket to this purpose. Direct-upload confirmation keeps ownership, pending-state, expiry, R2 HEAD existence, exact size, and matching Content-Type checks, including for files over 100 MiB. It does not download the object to inspect its container, codec, duration, resolution, or decodability. Multipart still transfers the bytes through the server, but skips media-content inspection for this purpose. This policy does not label metadata as server-verified and does not change ordinary uploads or public generation API behavior.
Upload response metadata
Both this multipart response and thePOST /api/v1/files/upload/confirm response include an optional video_metadata object in data when the upload used the influencer_reference_video purpose. It repeats the nine fields from the declaration table above with the same browser-declared values. It is omitted for ordinary uploads and for files recorded before this field existed.
The echoed object is still the client-provided declaration, not server-verified media evidence. Confirmation still uses R2 HEAD without reading the media, and multipart skips media-content inspection for this purpose. Do not treat the echoed values as measured output properties or as a substitute for your own validation.
Form Fields (multipart/form-data)
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | File binary data stream |
upload_path | string | No | Custom folder path (supports camelCase uploadPath) |
file_name | string | No | Custom file name (supports camelCase fileName) |
purpose | string | No | Use influencer_reference_video; see the browser-check section above. |
video_metadata | JSON string | With this purpose | The complete raw metadata object encoded as a string. |
Response Example
{
"success": true,
"code": 200,
"msg": "文件上传成功",
"data": {
"file_id": "file_349a227eaa054bab",
"file_name": "photo.png",
"original_name": "photo.png",
"file_size": 2048,
"mime_type": "image/png",
"upload_path": "photos",
"file_url": "https://api.omnimux.ai/api/v1/files/download/file_349a227eaa054bab",
"download_url": "https://api.omnimux.ai/api/v1/files/download/file_349a227eaa054bab",
"upload_time": "2026-09-10T23:49:59+08:00",
"expires_at": "2026-09-13T23:49:59+08:00"
}
}
purpose=influencer_reference_video, the stream and confirmation responses add the optional echo described above; it is absent for ordinary uploads:
Reference-video upload
{
"success": true,
"code": 200,
"msg": "文件上传成功",
"data": {
"file_id": "file_7c31a4f2d9e84b06",
"file_name": "reference.mp4",
"original_name": "reference.mp4",
"file_size": 1048576,
"mime_type": "video/mp4",
"upload_path": "influencer-reference/browser-upload",
"file_url": "https://api.omnimux.ai/api/v1/files/download/file_7c31a4f2d9e84b06",
"download_url": "https://api.omnimux.ai/api/v1/files/download/file_7c31a4f2d9e84b06",
"upload_time": "2026-10-19T10:00:00+08:00",
"expires_at": "2026-10-22T10:00:00+08:00",
"video_metadata": {
"duration": 7.072,
"video_duration": 7.041667,
"width": 1280,
"height": 720,
"frame_rate": 24,
"video_codec": "h264",
"audio_codec": "aac",
"container": "mp4",
"size_bytes": 1048576
}
}
}