文件未定义节点js

时间:2018-07-31 03:51:51

标签: javascript node.js

您知道如何在节点JS中执行下面的代码行吗?

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

谢谢。

1 个答案:

答案 0 :(得分:1)

您可以使用file system API中的writeFileSync()方法来写入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)