feat: Implement PDF recipe parser and quick import service for file and URL inputs
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { Controller, Post, Body } from '@nestjs/common';
|
||||
import { Body, Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { memoryStorage } from 'multer';
|
||||
import { QuickImportDto } from './dto/quick-import.dto';
|
||||
import { QuickImportService, QuickImportResult } from './quick-import.service';
|
||||
|
||||
@Controller('quick-import')
|
||||
@@ -6,9 +9,20 @@ export class QuickImportController {
|
||||
constructor(private readonly quickImportService: QuickImportService) {}
|
||||
|
||||
@Post()
|
||||
@UseInterceptors(
|
||||
FileInterceptor('file', {
|
||||
storage: memoryStorage(),
|
||||
limits: { fileSize: 10 * 1024 * 1024 },
|
||||
}),
|
||||
)
|
||||
async importFromInput(
|
||||
@Body() body: { input: string }
|
||||
@Body() body: QuickImportDto,
|
||||
@UploadedFile() file?: Express.Multer.File,
|
||||
): Promise<QuickImportResult> {
|
||||
return this.quickImportService.importFromInput(body.input);
|
||||
if (file) {
|
||||
return this.quickImportService.importFromUpload(file);
|
||||
}
|
||||
|
||||
return this.quickImportService.importFromInput(body?.input ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user