carga de archivos

This commit is contained in:
Andres2908
2022-02-02 22:29:46 -06:00
parent 3c87e1b7dc
commit 7c987c4327
8 changed files with 30 additions and 7 deletions
@@ -1,13 +1,15 @@
const moment = require('moment');
const fs = require('fs');
const {
validarNumeroEntero,
validarNumeroCuenta,
} = require('../../helper/validar');
const { eliminarArchivo } = require('../../helper/helper');
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Inscripcion = require(`${dbPath}/Inscripcion`);
const inscripcion = async (body) => {
const inscripcion = async (body, file) => {
const ahora = moment();
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
const idArea = validarNumeroEntero(body.idArea, 'id Area', true);
@@ -34,10 +36,16 @@ const inscripcion = async (body) => {
});
});
})
.then((res) => ({
message: '¡La inscripción se realizo de manera correcta!',
}))
.then(
(res) => (
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]),
{
message: '¡La inscripción se realizo de manera correcta!',
}
)
)
.catch((err) => {
eliminarArchivo(file.path);
throw new Error('No es posible realizar esta inscripción. ' + err);
});
};