DocsSchemas · FRL
On this page

Validate file fields

Set size, type, duration and quality requirements for files.

Before you begin: Store prices and references.

File Fields

File fields validate the stored file metadata generated by Frontbacked upload handling.

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

Video fields can control duration and the highest prepared quality:

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

Supported file rules:

RuleMeaning
requiredFile must be present.
maxSizeMaximum file size in bytes, up to the platform's 1GB upload limit.
mimeTypesAllowed MIME types.
minVideoDurationMinimum source video duration in seconds. Must be at least 1 second; fractional values such as 1.5 are supported. Shorter uploads fail preparation and schema validation.
maxVideoDurationMaximum prepared playback duration in seconds, within the platform's duration limit.
maxVideoQualityHighest quality to prepare: 240, 360, 480, 720, or 1080. Available qualities also depend on the source dimensions. Defaults to 1080.
videoDurationOverflow"reject" rejects a source longer than the maximum; "trim" prepares only the portion from the beginning through the maximum duration. "omit" leaves an overflowing optional file out of the saved data. On required file fields it behaves as "reject". With maxVideoDuration, the default is "reject".
maxDurationSecondsCompatibility spelling for older themes. Keeps its previous trim behavior; use maxVideoDuration and videoDurationOverflow for new themes.

For local development, install FFmpeg (including ffprobe) when using video duration or quality options. Unconstrained local uploads keep their original playback behavior.

The four video options also accept FRL expressions and helper functions. As elsewhere in FRL, call theme helpers with $fn.helperName(); bare calls such as helperName() are rejected. For example, let a site administrator configure a videoSettings page preference, and let a signed-in user's profile hold a quality preference:

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

Provide valid preference defaults before accepting uploads. Each function must return the same value type as the literal option; missing or invalid values reject preparation. Functions can use already-loaded page preferences and the uploading actor's data; storage requests, HTTP calls, and write operations are unavailable in video-option functions.

Video-option functions can also read $file.video.duration (seconds), $file.video.width, $file.video.height, and $file.video.hasAudio. These are verified source facts supplied by Frontbacked, alongside $file.size, $file.mimeType, and $file.fileName. They are available automatically while the option is evaluated; do not copy duration values from a browser into your post data.

backend/index.frl
Rule input (JSON)

Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.

Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.

Options are resolved after Frontbacked checks the uploaded source and are retained for that video's preparation. Duration checks use the source's playback timing instead of trusting its duration tag or browser metadata. The verified original duration is returned as media.source.duration; media.duration describes prepared playback.

Use videoDurationOverflow: "omit" to save the rest of a post or user profile while leaving an overlong optional video empty. On edit, this clears that optional field. In arrays of optional files, overflowing items are removed; other items remain in order. Nested optional file properties are removed from their objects. Normal array minimums and other schema rules still apply. A file with required: true continues to reject the whole write on overflow, even when "omit" is configured. Missing trusted duration facts still block the write until verification finishes.

frl

Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →

minVideoDuration must be at least 1 for both literal values and function results. Leaving this option unset does not add an explicit minimum.

videoDurationOverflow: "reject" and minimum-duration violations are schema errors: the entire post or user-profile create/edit action fails, including its other field changes. If source verification is still pending, the action fails with a "video is still being checked" error and may be submitted again after verification. Verification finishes before encoding, so a write does not have to wait for every quality. Restrictions are checked again when saving, including when reusing an existing upload or after preferences change. Selecting the same source again applies the current field limits. When existing qualities cover the requested duration and include an allowed resolution, Frontbacked reuses them without encoding again. Its player shows the capped duration, limits seeking and playback to that duration, and offers only allowed qualities. These limits belong to the saved attachment, so other uses of the same video keep their own limits. Increasing the limits extends each shorter quality only through its missing duration and prepares any missing qualities. Existing encoded segments are reused; reducing and restoring limits does not discard them. Preparation progress measures only the missing work being encoded. The current video stays intact while another version is prepared, and completed qualities are retained for retries. Newly prepared trims also apply to posters and thumbnails. Use the returned media playback URLs for prepared video.

The lowest quality, poster, and thumbnails become available together. media.progress reaches 100 when that first playable package is ready; higher qualities continue independently. media.qualities includes every planned quality and its availability, up to maxVideoQuality.

The stored file metadata must contain a valid url, size, mimeType, fileName, and uploadTime. Extra stored file metadata properties are rejected.

When video files are read back through FQL, Frontbacked may add a read-only media object with processing status and playback URLs. That object is for display and playback only, and is ignored on incoming writes before schema validation.

Continue with Generate and protect field values.