Overview
The upload endpoints allow authenticated users to upload files to the system. There are three dedicated endpoints, each configured for specific file types and storage locations:- Solicitud (Request) - For supporting documents attached to requests
- Comunicado (Announcement) - For media files in announcements (Admin only)
- Documento (Document) - For general administrative documents (Admin only)
Authentication
All upload endpoints require JWT authentication. Admin-specific endpoints additionally require Admin or Super Admin role.POST /api/uploads/solicitud
Upload supporting documents for employee requests (vacation requests, permission requests, etc.).Authorization
All Authenticated Users
Any authenticated employee can upload files for their own requests
Request
Content-Type:multipart/form-data
File to upload. Accepted file types and size limits are configured in the middleware.
Response
Whether the upload succeeded
Success or error message
Public URL to access the uploaded file. Format:
{BASE_URL}/uploads/solicitudes/{filename}Code Examples
cURL
JavaScript
Python
Example Response
POST /api/uploads/comunicado
Upload media files for announcements (images, PDFs, etc.).Authorization
Admin Access Required
Only Admin and Super Admin users can upload announcement media
Request
Content-Type:multipart/form-data
Media file to upload (image, PDF, etc.)
Response
Whether the upload succeeded
Success or error message
Public URL to access the uploaded file. Format:
{BASE_URL}/uploads/comunicados/{filename}Code Examples
cURL
JavaScript
Python
Example Response
POST /api/uploads/documento
Upload general administrative documents.Authorization
Admin Access Required
Only Admin and Super Admin users can upload administrative documents
Request
Content-Type:multipart/form-data
Document file to upload
Response
Whether the upload succeeded
Success or error message
Public URL to access the uploaded file. Format:
{BASE_URL}/uploads/documentos/{filename}Code Examples
cURL
JavaScript
Python
Example Response
Error Responses
All upload endpoints return the same error format:No file attached or invalid file
Forbidden (for admin-only endpoints)
Internal server error
Storage Locations
Solicitudes
public/uploads/solicitudes/Request supporting documentsComunicados
public/uploads/comunicados/Announcement media filesDocumentos
public/uploads/documentos/Administrative documentsImplementation Notes
- Files are processed by Multer middleware configured in
uploadMiddleware.js - Each endpoint has its own Multer configuration:
uploadSolicitud- For request documentsuploadComunicado- For announcement mediauploadDocumento- For administrative documents
- File naming: Timestamp prefix is added to prevent name collisions (e.g.,
1710234567890-filename.pdf) - The
BASE_URLenvironment variable determines the full URL returned - Files are stored in the
public/uploads/directory and served as static assets - File type restrictions and size limits are configured in the respective middleware
Usage Workflow
1. Upload File
Call the appropriate upload endpoint with the file
2. Receive URL
Get the public URL from the response
3. Store Reference
Save the URL in your request/announcement/document record