Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File is not defined node js

Do you have an idea how will I do theline of code below in node JS?

const file = new File([Data], `${filename}.card`, { type: 'application/octet-stream', lastModified: Date.now() });

Thanks.

like image 426
Jeson Avatar asked Nov 08 '22 04:11

Jeson


1 Answers

You can use the writeFileSync() method from the file system API to write to a file in Nodejs:

/* 
Example of data being transformed into a buffer suitable for writing 
to file:

const Data = [ 0, 1, 2, 3 ]; 
const buffer = Buffer.from(Data);
*/

fs.writeFileSync(`${filename}.card`, buffer)
like image 170
Dacre Denny Avatar answered Nov 14 '22 22:11

Dacre Denny