Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/lib/upload-limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@ export function getClientMaxUploadMb(): number {
return Math.min(parsed, MAX_UPLOAD_MB_CEILING);
}

/** True when a file exceeds the effective client pre-check limit. */
/**
* True when a file exceeds the effective client pre-check limit.
*
* This is deliberately the only size predicate exported: with the public env
* unset it falls back to the ceiling, so it subsumes the absolute
* "larger than any limit the server can accept" check. Keeping a second,
* ceiling-only predicate alongside it would let a call site silently bypass a
* lowered operator limit.
*/
export function exceedsClientUploadSize(sizeInBytes: number): boolean {
return sizeInBytes > getClientMaxUploadMb() * BYTES_PER_MB;
}

/** True when a file is larger than any limit the server can be configured to accept. */
export function exceedsUploadSizeCeiling(sizeInBytes: number): boolean {
return sizeInBytes > MAX_UPLOAD_MB_CEILING * BYTES_PER_MB;
}

/**
* The single wording for an over-limit file, so the pre-check reads exactly the
* same as the server's 413 rather than inventing a second phrasing.
Expand Down
Loading