Skip to content

Commit

Permalink
BC-5898 - add detected mime-type to FileDto (#4595)
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenWaysDP authored and bergatco committed Dec 6, 2023
1 parent ecfc6fc commit e1d062c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AntivirusService } from '@infra/antivirus';
import { S3ClientAdapter } from '@infra/s3-client';
import {
BadRequestException,
ConflictException,
Expand All @@ -8,8 +10,6 @@ import {
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { Counted, EntityId } from '@shared/domain';
import { AntivirusService } from '@infra/antivirus';
import { S3ClientAdapter } from '@infra/s3-client';
import { LegacyLogger } from '@src/core/logger';
import FileType from 'file-type-cjs/file-type-cjs-index';
import { PassThrough, Readable } from 'stream';
Expand All @@ -25,7 +25,7 @@ import {
import { FileDto } from '../dto';
import { FileRecord, ScanStatus } from '../entity';
import { ErrorType } from '../error';
import { FileStorageConfig, FILES_STORAGE_S3_CONNECTION } from '../files-storage.config';
import { FILES_STORAGE_S3_CONNECTION, FileStorageConfig } from '../files-storage.config';
import {
createCopyFiles,
createFileRecord,
Expand Down Expand Up @@ -81,6 +81,7 @@ export class FilesStorageService {
const { fileRecord, stream } = await this.createFileRecord(file, params, userId);
// MimeType Detection consumes part of the stream, so the restored stream is passed on
file.data = stream;
file.mimeType = fileRecord.mimeType;
await this.fileRecordRepo.save(fileRecord);

await this.createFileInStorageAndRollbackOnError(fileRecord, params, file);
Expand Down

0 comments on commit e1d062c

Please sign in to comment.