Skip to content

Commit

Permalink
update checks
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-singh-filestack committed Feb 2, 2024
1 parent 403e712 commit 18d104e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,27 @@ 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);

if (mime) {
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)) {
Expand All @@ -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;
}


};

Expand Down

0 comments on commit 18d104e

Please sign in to comment.