我正在节点中编写一个程序并使用replaceStream,我想将replacestream写入文件中,但是现在我能做的所有工作就是使用以下代码打印到控制台:

fs.createReadStream(filePath + "/" + fileName)
.pipe(replaceStream(imagePath, newPath))
.pipe(process.stdout);

最佳答案

只需将其写入writable stream

fs.createReadStream(filePath + "/" + fileName)
    .pipe(replaceStream(imagePath, newPath))
    .pipe(fs.createWriteStream(filePath + "/" + newFileName));

07-26 07:57