fix(upload): clear error and higher limit for large files

- raise upload limit to 100 MB
- return 413 file_too_large on MaxBytesError instead of misleading
  "expected multipart form"
- client-side per-file and total size pre-check with a clear message
This commit is contained in:
iu
2026-10-10 19:15:43 +03:00
parent 3886cc6511
commit b02b165b3d
2 changed files with 20 additions and 2 deletions
@@ -14,6 +14,8 @@
let progress = $state(0);
let error = $state('');
const MAX_SIZE = 100 * 1024 * 1024;
export function pick() {
fileInput?.click();
}
@@ -21,6 +23,16 @@
export function upload(files: FileList | File[]) {
const list = Array.from(files);
if (list.length === 0) return;
const tooBig = list.filter((f) => f.size > MAX_SIZE);
if (tooBig.length > 0) {
error = `Файл слишком большой: ${tooBig.map((f) => f.name).join(', ')}. Максимум 100 МБ.`;
return;
}
const total = list.reduce((sum, f) => sum + f.size, 0);
if (total > MAX_SIZE) {
error = 'Суммарный размер файлов превышает 100 МБ. Загрузите меньшими порциями.';
return;
}
error = '';
busy = true;
progress = 0;