From 5d770462bb91aa47230b20c5c241ac29ee057ca5 Mon Sep 17 00:00:00 2001 From: gary-singh-filestack Date: Thu, 4 Jan 2024 18:46:27 +0530 Subject: [PATCH] fix --- src/lib/utils/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 59abc8b9..641f312a 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -102,9 +102,13 @@ export const uniqueId = (len: number = 10): string => { * @returns {string} - mimetype */ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Promise => { - let type = await fromBuffer(file); - - const excludedMimetypes = ['text/plain', 'application/x-ms', 'application/x-msi', 'application/zip']; + let type; + try{ + type = await fromBuffer(file); + }catch(e){ + return 'application/octet-stream' + } + 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;