Spaces:
Runtime error
Runtime error
| import 'multer'; | |
| import { FilesInterceptor } from '@nestjs/platform-express'; | |
| import { UseInterceptors, UploadedFiles, Post, Controller, Bind } from '@nestjs/common'; | |
| import { MulterFiles } from '@/infra/http/utils/multer.file'; | |
| import { ExternalService } from '@/infra/http/services/external.service'; | |
| import { ImagePresenter } from '@/infra/http/presenters/image.presenter'; | |
| import { Image } from '@/domain/alcremie/enterprise/entities/image'; | |
| ('upload') | |
| export class UploadController { | |
| constructor(private readonly externalService: ExternalService) {} | |
| () | |
| (FilesInterceptor('image')) | |
| (UploadedFiles()) | |
| async uploadFile(files: MulterFiles) { | |
| let images: Image[] = []; | |
| for (let file of files) { | |
| const data = await this.externalService.uploadImage(file); | |
| if (data) { | |
| images.push(data); | |
| } | |
| } | |
| return { | |
| images: images.map(ImagePresenter.toHTTP), | |
| }; | |
| } | |
| } | |