import { Controller, Post, UploadedFiles, UseInterceptors, Body } from '@nestjs/common';
import { FilesInterceptor } from '@nestjs/platform-express';
import { PicturesService } from './pictures.service';

@Controller('pictures')
export class PicturesController {
  constructor(private readonly picturesService: PicturesService) {}

  @Post('upload')
  @UseInterceptors(FilesInterceptor('urlImg'))
  async uploadFile(@UploadedFiles() files: Express.Multer.File[], @Body() body: any) {
    // Aquí puedes acceder a los campos del formulario
    // console.log('Archivos:', files);
    // console.log('Otros campos del formulario:', body);
    const result = await this.picturesService.saveImages(files);
    
    return { data: result };
  }
}