feat: configurable upload file size limits via .env (#695)

* feat: make upload file size limits configurable via .env

Add UPLOAD_MAX_*_MB environment variables for documents, images, videos,
exercise assignment files, AI assistant documents, landing page images,
and media thumbnails. API presign routes validate file size server-side;
dashboard UI reads the same limits from layout data.

* chore: wire upload limit env vars through Docker compose and docs

Pass UPLOAD_MAX_*_MB from the root .env into api and dashboard containers
in both compose files, document them in .env.example and self-hosting guides.

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* docs: cross-link upload limits in README, Railway, Coolify, and Cloudflare guides

Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>

* fix: address PR review feedback on upload limits

- Restore 5 MB default for thumbnail uploads (edit-asset-dialog regression)
- Add getResolvedUploadLimits() fallback for Storybook/tests
- Cache core getUploadLimits() like the dashboard helper
- Document presign fileSize as advisory; allow zero-byte fileSize in schema
- Only send fileSize to presign when greater than zero

* docs: remove upload limits from Cloudflare setup guide

---------
This commit is contained in:
Rotimi Best
2026-06-29 12:48:51 +01:00
committed by GitHub
parent 65420320e7
commit a61942feb9
39 changed files with 411 additions and 79 deletions
@@ -14,6 +14,7 @@
import { InputField } from '@cio/ui/custom/input-field';
import { Button } from '@cio/ui/base/button';
import UploadCloudIcon from '@lucide/svelte/icons/upload-cloud';
import { getResolvedUploadLimits } from '$lib/utils/config/upload-limits-context';
interface Props {
imageURL?: string;
@@ -48,7 +49,8 @@
alt_description: string;
}[] = $state([]);
const MAX_IMAGE_SIZE = 500 * 1000;
const uploadLimits = getResolvedUploadLimits();
const maxLandingImageSize = uploadLimits.landingImageBytes;
async function handleImageClick(img: string) {
onchange?.(img);
@@ -58,7 +60,7 @@
}
function handleUnsupportedFile(file: File) {
if (file.size > MAX_IMAGE_SIZE) {
if (file.size > maxLandingImageSize) {
snackbar.error('snackbar.landing_page_settings.error.file_size');
return;
}
@@ -130,7 +132,7 @@
bind:src={cropperSrc}
onCropped={handleCropped}
onUnsupportedFile={handleUnsupportedFile}
maxFileSize={MAX_IMAGE_SIZE}
maxFileSize={maxLandingImageSize}
accept=".jpg, .jpeg, .png, .webp"
disabled={isUploading}
>