mirror of
https://github.com/gchq/CyberChef
synced 2025-12-30 15:13:36 +00:00
update file shim to use detectFileType.
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user