diff --git a/packages/bff/src/minio/minio.service.ts b/packages/bff/src/minio/minio.service.ts index 353800dc..223a7bca 100644 --- a/packages/bff/src/minio/minio.service.ts +++ b/packages/bff/src/minio/minio.service.ts @@ -21,6 +21,7 @@ export class MinioService { bucketName: string, filename: string, file: Buffer, + meta?: any, ): Promise { const _filename = `${uuid.v4()}.${filename.split('.').pop()}`; const result = await this.minioClient.putObject( @@ -31,7 +32,7 @@ export class MinioService { ); //const url = await this.getFileLink(bucketName, _filename); - return { result: { filename: _filename, msg: result } }; + return { filename: _filename, msg: result, meta: meta ?? {} }; } async getDownloadURL(bucketName: string, filename: string) { diff --git a/packages/bff/src/upload/dto/upload.dto.ts b/packages/bff/src/upload/dto/upload.dto.ts index e8791fc6..0aac17b6 100644 --- a/packages/bff/src/upload/dto/upload.dto.ts +++ b/packages/bff/src/upload/dto/upload.dto.ts @@ -19,5 +19,9 @@ export class MultiFileUploadDto { }, }) @IsNotEmpty() - files: any[]; + files: Express.Multer.File[]; + + @ApiProperty() + @IsNotEmpty() + meta: any; // or any other desired type, perhaps an object: meta: Record; } diff --git a/packages/bff/src/upload/upload.controller.ts b/packages/bff/src/upload/upload.controller.ts index 0a447403..375cb74a 100644 --- a/packages/bff/src/upload/upload.controller.ts +++ b/packages/bff/src/upload/upload.controller.ts @@ -1,5 +1,6 @@ import { BadRequestException, + Body, Controller, Get, Param, @@ -51,11 +52,14 @@ export class UploadController { type: MultiFileUploadDto, }) @UseInterceptors(FilesInterceptor('files')) - async upload(@UploadedFiles() files: Express.Multer.File[]) { + async upload( + @UploadedFiles() files: Express.Multer.File[], + @Body('meta') meta: any, + ) { try { if (!files || files?.length === 0) throw new BadRequestException('No Files passed'); - const urls = await this.uploadService.uploadFiles(files); + const urls = await this.uploadService.uploadFiles(files, meta); return urls; } catch (error) { throw error; diff --git a/packages/bff/src/upload/upload.service.ts b/packages/bff/src/upload/upload.service.ts index adc6032d..60a506ea 100644 --- a/packages/bff/src/upload/upload.service.ts +++ b/packages/bff/src/upload/upload.service.ts @@ -19,7 +19,7 @@ export class UploadService { return result; } - async uploadFiles(files: any) { + async uploadFiles(files: any, meta: any) { try { const urls = await Promise.all( files.map(async (file) => { @@ -27,11 +27,12 @@ export class UploadService { this.configService.get('MINIO_BUCKET'), file.originalname, file.buffer, + meta, ); return result; }), ); - return urls; + return { result: urls }; } catch (error) { throw error; }