Skip to Content

React Video Upload Component

Preview video metadata and posters, then connect a resumable upload client with pause, resume, cancel, retry, progress, and server-processing states.

Beta API maturity: Beta. This component is new and may evolve as its usage is validated.

VideoUpload composes the generic FileUpload selection and validation behavior with browser metadata and poster helpers from @puzzle-ui/media/browser. It does not transcode in the browser or contain server, router, storage, or transport code.

Inject a resumable upload action

The component reads duration, dimensions, aspect ratio, MIME type, and browser playback support, and generates a local poster preview. No upload starts unless you provide onUpload. The handler receives the source file plus an abort signal, metadata, poster, progress callback, and a server-status callback. Return a session with a done promise and any resumable controls your transport supports.

390 × 844

Resolving the session's done promise changes the upload state to uploaded; it does not claim that server processing is complete. Call onStatusChange("processing"), then "ready" when the backend reports completion, or "failed" with a message. The component presents distinct uploading, uploaded, processing, ready, and failed states. Pause, resume, and cancel buttons appear when supported by the returned session. A failed or cancelled item can be retried.

The example simulates a resumable client locally; it does not send files. Do not treat the browser metadata or poster as a security validation result. Enforce file policies again on your server.

Props

PropTypeDefaultDescription
acceptreadonly string[]["video/*"]Accepted MIME types.
multiplebooleanfalseAllow selecting multiple videos.
maxFilesnumber—Maximum selected video count in multiple mode.
maxFileSizenumber—Maximum source size in bytes per video.
maxTotalSizenumber—Maximum combined selected size in bytes.
maxDurationSecondsnumber—Reject videos longer than this duration.
posterOptionsVideoUploadProps["posterOptions"]Maximum 640 × 360, JPEGConfigure local poster dimensions, encoding, and frame time.
onUploadVideoUploadHandler—Inject a resumable upload action and return { done, pause?, resume?, cancel? }.
onChange(files: File[]) => void—Called when selection changes.
onProgress(file, progress) => void—Called with upload progress from 0 to 100.
onStatusChange(file, status) => void—Called when upload or server-processing state changes.

The injected context contains the source VideoMetadata, generated VideoPosterResult, AbortSignal, progress callback, and server status callback. The VideoUploadStatus, VideoUploadSession, VideoUploadHandler, and related types are exported from @puzzle-ui/ui. Other selection and validation props follow FileUploadProps.

Importing the component does not access browser globals. Metadata and poster APIs run only after a user selects a video, preserving server-rendered output without requiring client-side transcoding.