这是我的代码
let file = writeFile(filename, destination)
我请求链接并通过管道调用它。
reponse.pipe(file)
我的写功能
function writeFile(filename, destination) {
// console.log('ad',dir);
let num = 1;
let nm_wo_ext = filename.substr(0, filename.lastIndexOf("."));
let ext = filename.split(".").pop();
let jpath = path.join(destination, filename);
while (fs.existsSync(jpath)) {
// let f = nm_wo_ext + '('(num++) +ext
filename = `${nm_wo_ext} (${num++}).${ext}`;
jpath = path.join(destination, filename);
// console.log({jpath});
}
// fs.writeFileSync(jpath,data )
return fs.createWriteStream(jpath);
}
在这里如何关闭createwritestream?