From c88590f16c1976a60372a3af8dd1d4868a9ef1a8 Mon Sep 17 00:00:00 2001 From: Edgard Messias Date: Mon, 23 Nov 2020 15:28:21 -0300 Subject: [PATCH] fix: Fixed download JPEG image format --- src/api/layers/profile.layer.ts | 3 ++- src/api/layers/sender.layer.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/layers/profile.layer.ts b/src/api/layers/profile.layer.ts index 2351f1718..45095b8a7 100644 --- a/src/api/layers/profile.layer.ts +++ b/src/api/layers/profile.layer.ts @@ -117,6 +117,7 @@ export class ProfileLayer extends HostLayer { let b64 = await downloadFileToBase64(path, [ 'image/png', 'image/jpg', + 'image/jpeg', 'image/webp', ]); if (!b64) { @@ -124,7 +125,7 @@ export class ProfileLayer extends HostLayer { } if (b64) { const buff = Buffer.from( - b64.replace(/^data:image\/(png|jpeg|webp);base64,/, ''), + b64.replace(/^data:image\/(png|jpe?g|webp);base64,/, ''), 'base64' ); const mimeInfo = base64MimeType(b64); diff --git a/src/api/layers/sender.layer.ts b/src/api/layers/sender.layer.ts index 84930f9bd..80d267ef2 100644 --- a/src/api/layers/sender.layer.ts +++ b/src/api/layers/sender.layer.ts @@ -159,6 +159,7 @@ export class SenderLayer extends ListenerLayer { let base64 = await downloadFileToBase64(filePath, [ 'image/png', 'image/jpg', + 'image/jpeg', 'image/webp', ]); @@ -555,6 +556,7 @@ export class SenderLayer extends ListenerLayer { let b64 = await downloadFileToBase64(path, [ 'image/png', 'image/jpg', + 'image/jpeg', 'image/webp', ]); if (!b64) { @@ -562,7 +564,7 @@ export class SenderLayer extends ListenerLayer { } if (b64) { const buff = Buffer.from( - b64.replace(/^data:image\/(png|jpeg|webp);base64,/, ''), + b64.replace(/^data:image\/(png|jpe?g|webp);base64,/, ''), 'base64' ); const mimeInfo = base64MimeType(b64);