Spaces:
Runtime error
Runtime error
| import { | |
| Controller, | |
| Post, | |
| UseInterceptors, | |
| UploadedFile, | |
| Get, | |
| Param, | |
| BadRequestException, | |
| } from '@nestjs/common'; | |
| import { FileInterceptor } from '@nestjs/platform-express'; | |
| import { diskStorage } from 'multer'; | |
| import { extname } from 'path'; | |
| import { CaptureService } from './capture.service'; | |
| ('capture') | |
| export class CaptureController { | |
| constructor(private readonly service: CaptureService) {} | |
| ('upload') | |
| ( | |
| FileInterceptor('file', { | |
| storage: diskStorage({ | |
| destination: './uploads', | |
| filename: (req, file, cb) => { | |
| const uniqueName = `${Date.now()}-${Math.round(Math.random() * 1e9)}${extname(file.originalname)}`; | |
| cb(null, uniqueName); | |
| }, | |
| }), | |
| }), | |
| ) | |
| async uploadFile(() file: any) { | |
| if (!file) { | |
| throw new BadRequestException('No file provided'); | |
| } | |
| return this.service.processInvoice(file); | |
| } | |
| () | |
| findAll() { | |
| return this.service.findAll(); | |
| } | |
| (':id') | |
| findOne(('id') id: string) { | |
| return this.service.findOne(Number(id)); | |
| } | |
| } |