gitroomhq/postiz-app · error · HttpException
File is too large.
Error message
File is too large.
What it means
Before buffering the downloaded body, uploadsFromUrl compares the response's Content-Length header against the maximum allowed size for video (the largest cap, since the type isn't sniffed yet). If the declared size exceeds that cap, it throws 400 'File is too large.' to avoid OOM from buffering a huge file.
Source
Thrown at apps/backend/src/public-api/routes/v1/public.integrations.controller.ts:133
dispatcher: ssrfSafeDispatcher,
});
} catch {
// Network-level failure (DNS, connection refused, SSRF block, etc.) —
// fetch rejects rather than returning a non-ok response.
throw new HttpException({ msg: 'Failed to fetch URL' }, 400);
}
if (!response.ok) {
throw new HttpException({ msg: 'Failed to fetch URL' }, 400);
}
// Guard against OOM: bail out before buffering the whole body into memory.
// Content-Length may be absent or wrong, so we re-check the real size after
// download too. The type isn't known yet (sniffed below), so the pre-check
// uses the largest allowed cap (video).
const maxDownloadSize = getMaxSize('video/mp4');
const declaredSize = Number(response.headers.get('content-length'));
if (declaredSize && declaredSize > maxDownloadSize) {
throw new HttpException({ msg: 'File is too large.' }, 400);
}
const buffer = Buffer.from(await response.arrayBuffer());
const detected = await fileTypeFromBuffer(buffer);
if (!detected || !PUBLIC_API_ALLOWED_MIME.has(detected.mime)) {
throw new HttpException({ msg: 'Unsupported file type.' }, 400);
}
if (buffer.length > getMaxSize(detected.mime)) {
throw new HttpException({ msg: 'File is too large.' }, 400);
}
const mimetype = detected.mime;
const ext = detected.ext;
const getFile = await this.storage.uploadFile({
buffer,
mimetype,View on GitHub (pinned to 0f1647f749)
Solutions
- Check the file's Content-Length (curl -I) and compress/downscale it below the allowed video cap before passing the URL
- Use the direct upload endpoint for large files if applicable
- If the header is wrong on your server, fix the origin to report accurate Content-Length
Example fix
// before
{ "url": "https://example.com/4k-raw-video.mov" } // 2GB
// after
{ "url": "https://example.com/compressed-video.mp4" } // under the size cap Defensive patterns
Strategy: validation
Validate before calling
const size = Number((await fetch(url, { method: 'HEAD' })).headers.get('content-length'));
if (size > MAX_VIDEO_CAP) throw new Error(`File is ${size} bytes — compress below the cap`); Type guard
null
Try / catch
null
Prevention
- Check Content-Length via HEAD before submitting
- Compress videos below the platform cap
- Keep accurate Content-Length headers on your origin
When it happens
Trigger: POST /public/v1/uploads/from-url pointing at a file whose Content-Length header exceeds the video max size (e.g. a 500MB mp4 when the cap is lower), or a server that reports an inflated/incorrect Content-Length.
Common situations: Trying to side-load large videos instead of using the direct upload route; CDN misreporting sizes; developers unaware that URL-based upload enforces the same size caps as multipart upload.
Related errors
- Unsupported file type.
- All media must be uploaded through our upload API route and
- File size exceeds the maximum allowed size of ${maxSize} byt
- Failed to fetch URL
- Post validation failed
AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27).
Data as JSON: /api/errors/b523d7d2715d6c88.
Report an issue: GitHub.