Skip to content

Commit

Permalink
fix and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-singh-filestack committed Jan 4, 2024
1 parent db215ba commit 4ca71ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib/utils/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const ExtensionsMap = {
'application/octet-stream': [
'bin',
'dms',
'tdms',
'lrf',
'mar',
'so',
Expand Down
8 changes: 6 additions & 2 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ export const uniqueId = (len: number = 10): string => {
* @returns {string} - mimetype
*/
export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Promise<string> => {
let type = await fromBuffer(file);

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) {
Expand Down

0 comments on commit 4ca71ba

Please sign in to comment.