Node.JS WriteFile - File of specific size

时间:2015-06-20 09:35:11

标签: javascript node.js

Is there a way to specify the size/length of a file and have the system reserve the space needed? I'm looking for something like:

fs.write('file', Buffer, 1024*1024*54); // To create 54MB file.

1 个答案:

答案 0 :(得分:5)

Just create a Buffer of that size?

fs.writeFile('file', new Buffer(1024*1024*54));