import { MulterOptions } from "@nestjs/platform-express/multer/interfaces/multer-options.interface"; /** * Ceiling for a single uploaded document, in bytes. * * Mirrors the 50MB `max_size_mb` the file-upload settings hand the portal, so * the client-side gate and the server-side cap agree. Raising this alone is not * enough to accept a 50MB upload: the reverse proxy in front of the API applies * its own `client_max_body_size`, and nginx's 1MB default rejects the request * with a 413 before it ever reaches Nest (see docs/uploads.md). */ export const DOCUMENT_UPLOAD_MAX_BYTES = 50 * 1024 * 1024; /** Upper bound on parts in one multipart document post. */ export const DOCUMENT_UPLOAD_MAX_FILES = 20; /** * Multer caps for the document upload routes. * * Without an explicit `fileSize`, multer's default is unlimited and every byte * is buffered in memory, so an oversized post is absorbed in full before * anything can reject it. With the limit set, multer stops reading the socket * at the ceiling instead. */ export const documentUploadMulterOptions: MulterOptions = { limits: { fileSize: DOCUMENT_UPLOAD_MAX_BYTES, files: DOCUMENT_UPLOAD_MAX_FILES, }, };