我有一个数据流,我需要把它写到任何地方,但没有立即停止它。下面的代码写到一个文件中,因此只要流运行,它就会保持连接的活力。
request
.get(href)
.on('response', function(response) {
console.log(response.statusCode)
console.log(response.headers['content-type'])
})
.pipe(fs.createWriteStream("name.mp3"))是否有可能在保持像fs.createWritableStream这样的连接的同时,将该流输送到任何地方?
我试过使用dev-null (npm包),但它似乎会立即关闭连接。
发布于 2019-01-07 14:39:54
这似乎是一个奇怪的问题,但也许您可以使用/dev/null,或者在下面的文章中说明与Windows相当的内容?
How can I write to the NUL device under Windows from node.js?
我确实看到您尝试过类似于dev-null包的东西,但是也许可以尝试不带包,看看它是否有效。
发布于 2022-07-13 17:49:02
在linux上不需要任何软件包(参见almarc对Hein关于Windows的答复的评论):
request
.get(href)
.on('response', function(response) {
console.log(response.statusCode)
console.log(response.headers['content-type'])
})
.pipe(fs.createWriteStream("/dev/null")).https://stackoverflow.com/questions/54076329
复制相似问题