Marbes uses multer for all file uploads. Every upload middleware stores files in memory first (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/scoria02/marbes2021_backend/llms.txt
Use this file to discover all available pages before exploring further.
multer.memoryStorage()), then the relevant service layer processes and writes them to the uploads/ directory on disk. All uploads are validated by MIME type and file size before being accepted. Uploaded files are then served as static assets via GET /uploads/{path}.
Static file serving
Once uploaded, files are accessible at:uploads/ directory at the project root using Express static middleware:
Avatar uploads
Employee avatars are uploaded viaPUT /api/rrhh/user/editar. The endpoint accepts a single image file in the avatar field of a multipart/form-data request.
Accepted types: image/jpeg, image/jpg, image/png, image/gif, image/webpMax size: 5 MB
Max files: 1 After upload, the image is processed with sharp:
- Resized to 300 × 300 px using
coverfit (center-aligned) - Re-encoded as JPEG at 85% quality
- Saved to
uploads/{userId}/avatar_{timestamp}.jpg - Any previous
avatar_*file in the user’s directory is deleted automatically
uploads/abc123/avatar_1716000000000.jpg.
Contract PDF uploads
Signed contract PDFs are uploaded viaPOST /api/rrhh/contrato/cliente/:id. The middleware uploadContratoPDFMiddleware accepts a single PDF in the contrato_pdf field.
Accepted types: application/pdf onlyMax size: 10 MB
Max files: 1 Files are saved to:
uploadContratoPDFMiddleware) is also used for signed vínculo PDFs via POST /api/rrhh/vinculo/cliente/:id, which saves to:
Both contract and vínculo PDF endpoints use the same
contrato_pdf field name. Make sure you are POSTing to the correct endpoint for each document type.Guarantee file uploads
Guarantee documents are attached to contracts (viaPOST /api/negocios/contratos/actualizar/:id) and to TPROD loan products (via POST /api/negocios/tprod). Both use uploadGarantiaFiles, which calls multer.any() and accepts files under any field name.
Accepted types: PDF, Word (.doc/.docx), Excel (.xls/.xlsx), plain text, JPEG, PNG, GIF, WebPMax size per file: 10 MB
Max files: 10 Images are resized (max width 1600 px, no enlargement) and re-encoded as JPEG at 85% quality. Non-image documents are written to disk as-is. Storage paths:
| Context | Path pattern |
|---|---|
| Contract guarantee | uploads/{idAportante}/{idContrato}/garantias/garantia_{name}_{timestamp}{ext} |
| TPROD guarantee | uploads/{idCliente}/tprod/{idTprod}/garantias/garantia_{name}_{timestamp}{ext} |
Excel and CSV uploads
Bank statement files are uploaded for processing viauploadExcelMiddleware, which calls multer.any() and accepts files under any field name (common names: archivo, file, excel, estadoCuenta).
Accepted types: .xls, .xlsx, .csv (validated by both MIME type and file extension)Max size: 15 MB
Max files: 1 Accepted MIME types:
application/vnd.ms-excelapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.oasis.opendocument.spreadsheettext/csvtext/plain(CSV sometimes detected as this)application/csv
Credit application document uploads
Credit application documents are handled byuploadSolicitudCreditoDocs, which calls multer.any() and accepts files under any field name. This allows the front end to send fields like doc_cedula_url, doc_rif_url, doc_acta_constitutiva_url, declaracion_jurada, and logo without triggering a multer Unexpected field error.
Accepted types: PDF (including application/octet-stream with .pdf extension), JPEG, PNGMax size per file: 15 MB
Max files: 30
Credit application endpoints accept either a standard JWT (
Authorization: Bearer) or a one-time link token (X-Solicitud-Token header or token body field). See Roles and permissions for details on authOrSolicitudToken.Client credit document uploads (n8n integration)
Documents for credit clients can be uploaded by n8n automations viaPOST /api/rrhh/clientes-creditos/:id/documentos. This endpoint supports two delivery modes:
Mode A — multipart/form-data with fields data, doc_empresa[], registro_mercantil[], or doc_representante[] (up to 10 files each, 30 total).
Mode B — raw binary body with Content-Type: application/pdf or application/octet-stream. The rawPdfBodyMiddleware reads the body into a buffer before multer runs. The filename is resolved from Content-Disposition, X-File-Name, or X-Original-Filename headers, falling back to documento_{timestamp}.pdf.
Accepted types (multipart): application/pdf, image/jpeg, image/jpg, image/png, application/octet-streamMax size per file: 15 MB
Max files: 30 Files are stored at:
tipo_documento_slug is derived from the document type label by lowercasing, replacing spaces with _, and stripping special characters.
Upload limits summary
| Middleware | Field name(s) | Types | Max size | Max files |
|---|---|---|---|---|
uploadAvatar | avatar | JPEG, PNG, GIF, WebP | 5 MB | 1 |
uploadContratoPDFMiddleware | contrato_pdf | 10 MB | 1 | |
uploadGarantiaFiles | any | PDF, Word, Excel, TXT, images | 10 MB | 10 |
uploadExcelMiddleware | any | XLS, XLSX, CSV | 15 MB | 1 |
uploadSolicitudCreditoDocs | any | PDF, JPEG, PNG | 15 MB | 30 |
cpUpload | data, doc_empresa[], registro_mercantil[], doc_representante[] | PDF, JPEG, PNG | 15 MB | 30 |
uploadReferencia | referencia_img | any | 10 MB | 1 |