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;