forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

upload-limits.ts13 lines, 474 bytesHistoryRawDownload
1import type { SchoolSettings } from "@/api/client";
2
3export const DEFAULT_MAX_FILE_BYTES = 5 * 1024 * 1024;
4
5export function maxUploadBytes(settings: SchoolSettings | null | undefined): number {
6 return settings?.max_file_bytes ?? DEFAULT_MAX_FILE_BYTES;
7}
8
9export function formatBytes(bytes: number): string {
10 if (bytes < 1024) return `${bytes} B`;
11 if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
12 return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
13}