mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
File shim now translates correctly
This commit is contained in:
parent
d080c5dd14
commit
2019ae43d7
7 changed files with 14 additions and 28 deletions
|
@ -19,21 +19,21 @@ class File {
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* https://w3c.github.io/FileAPI/#file-constructor
|
||||
*
|
||||
* @param {String|Array|ArrayBuffer|Buffer} bits - file content
|
||||
* @param {String} name (optional) - file name
|
||||
* @param {Object} stats (optional) - file stats e.g. lastModified
|
||||
*/
|
||||
constructor(data, name="", stats={}) {
|
||||
// Look at File API definition to see how to handle this.
|
||||
this.data = Buffer.from(data[0]);
|
||||
const buffers = data.map(d => Buffer.from(d));
|
||||
const totalLength = buffers.reduce((p, c) => p + c.length, 0);
|
||||
this.data = Buffer.concat(buffers, totalLength);
|
||||
|
||||
this.name = name;
|
||||
this.lastModified = stats.lastModified || Date.now();
|
||||
this.type = stats.type || mime.getType(this.name);
|
||||
|
||||
console.log('File constructor');
|
||||
console.log(typeof data);
|
||||
console.log(data);
|
||||
console.log(this.data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue