Skip to main content

Upload File

curl -X POST https://api.vlife-dgo.com/FileUpload/UploadFile \
  -H "Content-Type: multipart/form-data" \
  -F "[email protected]" \
  -F "evalID=12345" \
  -F "documentoID=8" \
  -F "enctyptedData=abc123xyz"
Uploads a document file associated with an employee evaluation.

Endpoint

POST /FileUpload/UploadFile

Authentication

Requires active user session (isLoggedIn middleware).

Request Body

file
file
required
The PDF file to upload. Must be in PDF format.
evalID
integer
required
The evaluation ID to associate the document with.
documentoID
integer
required
The document type ID from the catalog (cat_dgo_documentos).
enctyptedData
string
required
Encrypted evaluation data for redirect purposes.

File Upload Configuration

  • Content Type: multipart/form-data
  • Max File Size: 20 MB (20,000,000 bytes)
  • Accepted Formats: PDF only
  • Storage Location: src/public/uploads/
  • Naming Strategy: UUID v4 + day + month + .pdf
    • Example: 550e8400-e29b-41d4-a716-446655440000823.pdf

Response

redirect
string
Redirects to /evaluacionvLife/evaluacionView/{enctyptedData} on success.
flash.success
string
“Documento cargado con exito” - Displayed on successful upload.

Error Responses

flash.message
string
Error message displayed to the user.
File Size Error
{
  "flash": {
    "message": "El archivo excede los 20MB"
  }
}
Returns when file exceeds the 20MB limit and redirects back to the previous page. General Error
{
  "flash": {
    "message": "Algo salio mal !"
  }
}
Returns on database errors or other unexpected issues.

Implementation Details

Multer Configuration (app.js:64-85)
const storage = multer.diskStorage({
  destination: path.join(__dirname, 'public/uploads'),
  filename: (req, file, cb) => {
    const fecha = new Date()
    const mes = fecha.getMonth() + 1
    const dia = fecha.getDay()
    cb(null, uuidv4() + dia + mes + '.pdf')
  }
})

app.use(multer({
  storage: storage,
  limits: { fileSize: 20000000 },
}).single('file'), fileSizeLimitErrorHandler)
Database Operation (FileUploadController.js:43-56) The uploaded file metadata is saved to tbl_dgo_uploads table:
INSERT INTO tbl_dgo_uploads SET ?
Data packet includes:
  • evalID: Evaluation identifier
  • documentoID: Document type identifier
  • uploadFileName: Generated UUID filename

Delete File

curl -X POST https://api.vlife-dgo.com/FileUpload/DeleteFile \
  -H "Content-Type: application/json" \
  -d '{
    "uploadID": 456
  }'
Soft deletes a previously uploaded document by setting its active flag to 0.

Endpoint

POST /FileUpload/DeleteFile

Authentication

Requires active user session (isLoggedIn middleware).

Request Body

uploadID
integer
required
The unique identifier of the upload record to delete.

Response

flash.success
string
“Documento borrado con exito” - Displayed on successful deletion.
redirect
string
Redirects back to the previous page.

Error Response

{
  "flash": {
    "message": "Algo salio mal !"
  }
}

Database Operation

UPDATE tbl_dgo_uploads SET uploadActivo = 0
WHERE uploadID = ?
This performs a soft delete by setting the uploadActivo flag to 0 rather than removing the record.

Get File Upload View

curl -X GET https://api.vlife-dgo.com/FileUpload/FileUploadView/8/abc123xyz
Returns the file upload interface view for a specific document type.

Endpoint

GET /FileUpload/FileUploadView/:documentoID/:enctyptedData

Authentication

Requires active user session (isLoggedIn middleware).

Path Parameters

documentoID
integer
required
The document type ID to retrieve information for.
enctyptedData
string
required
Encrypted evaluation data (ncrypt-js encrypted string).

Response

Returns an HTML view (fileUpload/fileUploadView) with:
user
string
Current user’s name from session.
enctyptedData
string
The encrypted data passed in the URL.
decryptedData
string
Decrypted evaluation ID.
documentoID
integer
The document type identifier.
InfoDocument
object
Document type information from cat_dgo_documentos catalog.
numLeyenda
integer
Legend number (only included when documentoID = 8).

Database Query

SELECT * 
FROM cat_dgo_documentos
WHERE documentoID = ?

Income Reason Management

Add Income Reason

curl -X POST https://api.vlife-dgo.com/FileUpload/IngresosMotivo \
  -H "Content-Type: application/json" \
  -d '{
    "evalID": 12345,
    "motivoDescripcion": "Salario adicional por horas extra",
    "enctyptedData": "abc123xyz"
  }'

Endpoint

POST /FileUpload/IngresosMotivo

Request Body

evalID
integer
required
The evaluation ID.
motivoDescripcion
string
required
Description of the income reason.
enctyptedData
string
required
Encrypted evaluation data for redirect.

Response

flash.success
string
“Se guardo motivo” - Displayed on success.

Delete Income Reason

curl -X POST https://api.vlife-dgo.com/FileUpload/DeleteMotivo \
  -H "Content-Type: application/json" \
  -d '{
    "evalID": 12345
  }'

Endpoint

POST /FileUpload/DeleteMotivo

Request Body

evalID
integer
required
The evaluation ID to remove income reasons for.

Response

flash.success
string
“Motivo eliminado” - Displayed on successful deletion.

Database Operation

UPDATE tbl_dgo_motivos_ingresos SET motivoActivo = 0 
WHERE evalID = ?

Build docs developers (and LLMs) love