【发布时间】:2023-03-29 08:33:01
【问题描述】:
这就是我所拥有的,我一直收到错误消息,因为当我按顺序执行时文件还不存在。
如何在 writeStream 关闭时触发操作?
var fs = require('fs'), http = require('http');
http.createServer(function(req){
req.pipe(fs.createWriteStream('file'));
/* i need to read the file back, like this or something:
var fcontents = fs.readFileSync(file);
doSomethinWith(fcontents);
... the problem is that the file hasn't been created yet.
*/
}).listen(1337, '127.0.0.1');
【问题讨论】: