如何在Node.js中创建附加writeStream [英] How to create appending writeStream in Node.js

查看:118
本文介绍了如何在Node.js中创建附加writeStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前文档此处似乎没有提及任何控制流的参数关于文件是每次重新创建还是仅附加数据的行为.

Current documentation here doesn't seem to mention any parameters governing the stream's behaviour with regards to whether file is re-created every time or just gets data appended.

有没有一种方法可以创建一个writeStream来追加数据?

Is there a way to create a writeStream which appends the data?

推荐答案

有一个 createWriteStream 在其下方.

fs.createWriteStream(path,[options]) 返回一个新的WriteStream对象(请参见 可写流).

fs.createWriteStream(path, [options]) Returns a new WriteStream object (See Writable Stream).

options是带有 以下默认值:

options is an object with the following defaults:

{ 'flags': 'a'
, 'encoding': null
, 'mode': 0666
}

这篇关于如何在Node.js中创建附加writeStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆