carga de archivos
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user