diff --git a/apps/file-service/src/utils/fileTypeDetector.ts b/apps/file-service/src/utils/fileTypeDetector.ts index 6bb4fc7930..3ee32f3f01 100644 --- a/apps/file-service/src/utils/fileTypeDetector.ts +++ b/apps/file-service/src/utils/fileTypeDetector.ts @@ -18,7 +18,9 @@ export class FileTypeDetector { async detect() { const start = Date.now(); - const response = (await this.createCustomConcatStream(this.content)) as CustomConcatStream; + let response = (await this.createCustomConcatStream(this.content)) as CustomConcatStream; + + response = this.validateSVGMimeType(response); const fullStream = response.fileStream; const fileType = response.fileType; @@ -32,6 +34,14 @@ export class FileTypeDetector { return response; } + // Need to add base64 to the end of the mime so that the pdf can embed the svg correctly. + validateSVGMimeType(response: CustomConcatStream) { + if (response?.fileType?.mime == 'image/svg+xml') { + response.fileType.mime = `${response?.fileType.mime};base64`; + } + return response; + } + private createCustomConcatStream(readableStream) { return new Promise((resolve, reject) => { const customStream = new Readable({