Se modificaron varias cosas y se agrego un endpoint nuevo para hacer pruebas
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
numeroCuenta,nombre,licenciatura,correo,fechaInicio,fechaFin,fechaLiberacion,institucion,dependencia,programa,profesor,clave,status
|
||||
315040357,RAMIREZ AVILA MELANY BETSABE,LIC. EN HISTORIA,424018289@pcpuma.acatlan.unam.mx,29/7/2024,3/12/2025,"",Instituto Nacional De Antropologia E Historia,Museo Nacional De Antropologia,"Investigación, conservación y difusión del patrimonio arqueológico y etnográfico de México","",2024-21/7-1471,Pre-Termino
|
||||
319304899,ASCENCIO DIAZ ENRIQUE,LIC. EN ACTUARIA,424018289@pcpuma.acatlan.unam.mx,27/10/2024,1/12/2025,"",UNAM,FES ACATLAN,Acatlán Contigo,Act. Jorge Carmona Mendoza,2025-12/145-24,Cancelado
|
||||
413076379,JIMENEZ GONZALEZ JAZMIN ALEJANDRA,LIC. EN MATEMATICAS APLICADAS Y COMP.,424018289@pcpuma.acatlan.unam.mx,1/12/2025,4/12/2025,"",UNAM,FES ACATLAN,Acatlán Contigo,xxxx,2025-12/145-24,Pre-Registro
|
||||
|
||||
|
@@ -12,6 +12,7 @@ import {
|
||||
Res,
|
||||
ParseIntPipe,
|
||||
Param,
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import {
|
||||
FileInterceptor,
|
||||
@@ -30,6 +31,19 @@ export class ServicioController {
|
||||
|
||||
// ------------------ POST ------------------
|
||||
|
||||
// Garegue un nuevo endpoint para hacer pruebas
|
||||
@Post('test-upload')
|
||||
@UseInterceptors(FileInterceptor('file'))
|
||||
uploadTest(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Req() req: any,
|
||||
) {
|
||||
console.log('FILE:', file);
|
||||
console.log('FILES REQ:', req.file);
|
||||
console.log('FILES BODY:', req.body);
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
@Post('nuevo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
@@ -38,6 +52,9 @@ export class ServicioController {
|
||||
@Body('alumno') alumnoJson: string,
|
||||
) {
|
||||
const dto: CrearServicioDto = JSON.parse(alumnoJson);
|
||||
|
||||
console.log('Archivo recibido:', file);
|
||||
|
||||
return await this.servicioService.registrarNuevoServicio(dto, file);
|
||||
}
|
||||
|
||||
|
||||
@@ -643,7 +643,29 @@ export class ServicioService {
|
||||
): Promise<{ message: string }> {
|
||||
// 🔹 Validaciones
|
||||
|
||||
const archivoPath = `./server/uploads/${this.validacionService.validacionBasicaStr(file, 'archivo', true, 1000)}`;
|
||||
// Agregue una validacion para el archivo
|
||||
if (!file) {
|
||||
throw new BadRequestException('No se ha proporcionado un archivo.');
|
||||
}
|
||||
|
||||
/* Codigo anterior
|
||||
const archivoPath = `./server/uploads/${this.validacionService.validacionBasicaStr(file.filename, 'archivo', true, 1000)}`;
|
||||
*/
|
||||
// Hacemos una validacion en el nombre
|
||||
const nombreArchivo = `./server/uploads/${this.validacionService.validacionBasicaStr(file.filename, 'archivo', true, 1000)}`;
|
||||
|
||||
const archivoPath = `./server/uploads/${nombreArchivo}`;
|
||||
|
||||
// Validacion de tipo de archivo
|
||||
if (file.mimetype !== 'application/pdf') {
|
||||
throw new BadRequestException('La carta debe ser un archivo PDF.');
|
||||
}
|
||||
|
||||
// Validacion de tamanio
|
||||
if (file.size > 5 * 1024 * 1024) {
|
||||
throw new BadRequestException('La carta debe ser menor a 5MB.');
|
||||
}
|
||||
|
||||
const progInterno = dto.programaInterno
|
||||
? this.validacionService.validarAlfanumerico(
|
||||
dto.programaInterno,
|
||||
|
||||
Reference in New Issue
Block a user