mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
update file shim to use detectFileType.
This commit is contained in:
parent
4add484d2a
commit
aad1bc898e
4 changed files with 25 additions and 4 deletions
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
import mime from "mime";
|
||||
import { detectFileType } from "../core/lib/FileType";
|
||||
|
||||
|
||||
/**
|
||||
* FileShim
|
||||
|
@ -37,8 +39,13 @@ class File {
|
|||
|
||||
this.name = name;
|
||||
this.lastModified = stats.lastModified || Date.now();
|
||||
this.type = stats.type || mime.getType(this.name);
|
||||
|
||||
const types = detectFileType(this.data);
|
||||
if (types.length) {
|
||||
this.type = types[0].mime;
|
||||
} else {
|
||||
this.type = "application/unknown";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue