se agrego drive correctamente
This commit is contained in:
@@ -26,6 +26,7 @@ import { ServiciosAdminDto } from './dto/servicios-admin.dto';
|
||||
import { ServiciosResponsableDto } from './dto/servicios-responsable.dto';
|
||||
import { RegistroValidadoDto } from './dto/registro-validado.dto';
|
||||
import { multerConfig } from './multer';
|
||||
import { diskStorage } from 'multer';
|
||||
|
||||
@Controller('servicio')
|
||||
export class ServicioController {
|
||||
@@ -55,7 +56,15 @@ export class ServicioController {
|
||||
|
||||
@Post('nuevo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion', {
|
||||
storage: diskStorage({
|
||||
destination: './server/uploads',
|
||||
filename: (req, file, cb) => {
|
||||
cb(null, Date.now() + '-' + file.originalname);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
async crearServicio(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('alumno') alumnoJson: string,
|
||||
@@ -129,20 +138,38 @@ export class ServicioController {
|
||||
}
|
||||
|
||||
@Put('carta_aceptacion')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaAceptacion'))
|
||||
//@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(
|
||||
FileInterceptor('cartaAceptacion', {
|
||||
storage: diskStorage({
|
||||
destination: './server/uploads',
|
||||
filename: (req, file, cb) => {
|
||||
cb(null, Date.now() + '-' + file.originalname);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
async subirCartaAceptacion(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
) {
|
||||
const body = JSON.parse(dataJson);
|
||||
console.log('file:', file)
|
||||
return this.servicioService.cartaTermino(body.idServicio, file);
|
||||
return this.servicioService.cartaTermino(body.idServicio, file.filename);
|
||||
}
|
||||
|
||||
@Put('carta_termino')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('cartaTermino'))
|
||||
@UseInterceptors(
|
||||
FileInterceptor('cartaTermino', {
|
||||
storage: diskStorage({
|
||||
destination: './server/uploads',
|
||||
filename: (req, file, cb) => {
|
||||
cb(null, Date.now() + '-' + file.originalname);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
async subirCartaTermino(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
@@ -154,7 +181,16 @@ export class ServicioController {
|
||||
|
||||
@Put('informe_global')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(FileInterceptor('informeGlobal'))
|
||||
@UseInterceptors(
|
||||
FileInterceptor('informeGlobal', {
|
||||
storage: diskStorage({
|
||||
destination: './server/uploads',
|
||||
filename: (req, file, cb) => {
|
||||
cb(null, Date.now() + '-' + file.originalname);
|
||||
},
|
||||
}),
|
||||
}),
|
||||
)
|
||||
async subirInformeGlobal(
|
||||
@UploadedFile() file: Express.Multer.File,
|
||||
@Body('data') dataJson: string,
|
||||
@@ -193,7 +229,7 @@ export class ServicioController {
|
||||
}
|
||||
|
||||
@Put('update')
|
||||
//@UseGuards(AuthGuard('jwt'))
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@UseInterceptors(
|
||||
FileFieldsInterceptor([
|
||||
{ name: 'cartaAceptacion', maxCount: 1 },
|
||||
|
||||
@@ -273,7 +273,7 @@ export class ServicioService {
|
||||
};
|
||||
}
|
||||
|
||||
async cartaTermino(idServ: number, file: Express.Multer.File) {
|
||||
async cartaTermino(idServ: number, file: string) {
|
||||
const idServicio = this.validacionService.validarNumeroEntero(
|
||||
idServ,
|
||||
'id servicio',
|
||||
@@ -373,7 +373,7 @@ export class ServicioService {
|
||||
throw new BadRequestException('El archivo debe ser PDF');
|
||||
}
|
||||
|
||||
const rutaArchivo = `./server/uploads/${archivo.originalname}`;
|
||||
const rutaArchivo = `./server/uploads/${archivo.filename}`;
|
||||
// Hasta aqui termine de agregar las lineas
|
||||
|
||||
// 🔹 Validar archivo y generar path local
|
||||
@@ -515,7 +515,7 @@ export class ServicioService {
|
||||
|
||||
// 🔹 Validar archivo y generar path local
|
||||
const rutaArchivo: string = `./server/uploads/${this.validacionService.validacionBasicaStr(
|
||||
archivo,
|
||||
archivo.filename,
|
||||
'archivo',
|
||||
true,
|
||||
1000,
|
||||
|
||||
Reference in New Issue
Block a user