From 18d104ea1627b443671b793f081e239fa98368d3 Mon Sep 17 00:00:00 2001 From: gary-singh-filestack Date: Fri, 2 Feb 2024 16:54:43 +0530 Subject: [PATCH] update checks --- src/lib/utils/index.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 60ed7371..e85ead2e 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -106,13 +106,11 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom try { type = await fromBuffer(file); } catch(e) { - console.log('name: ',name) // A temporary solution for some PNG files when resized if (name == undefined){ return 'image/png'; } } - console.log('name2: ',name) if (name && name.indexOf('.') > -1) { const mime = extensionToMime(name); @@ -120,11 +118,15 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom return mime; } } - const excludedMimetypes = ['text/plain','image/png', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip']; + const excludedMimetypes = ['text/plain', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip']; if (type && excludedMimetypes.indexOf(type.mime) === -1) { return type.mime; } + // if we cant find types by extensions and we have magic bytes fallback to it + if (type) { + return type.mime; + } try { if (isutf8(file)) { @@ -137,10 +139,7 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom // this is only fallback, omit it in coverage /* istanbul ignore next */ - // if we cant find types by extensions and we have magic bytes fallback to it - if (type) { - return type.mime; - } + };