Spaces:
Runtime error
Runtime error
Download src/capture/capture.controller.ts from ukzada/invoice-ocr-temp: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/ukzada/invoice-ocr-temp/resolve/main/src/capture/capture.controller.ts
- Command line
-
hf download hf://spaces/ukzada/invoice-ocr-temp/src/capture/capture.controller.ts
-
curl -L -o capture.controller.ts https://huggingface.co/spaces/ukzada/invoice-ocr-temp/resolve/main/src/capture/capture.controller.ts
1.17 kB
| 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)); | |
| } | |
| } |