您知道如何在节点JS中执行下面的代码行吗?
const file = new File([Data], `${filename}.card`, { type: 'application/octet-stream', lastModified: Date.now() });
谢谢。
答案 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)