To upload a file locally I'm using the following code:
import {pipeline} from "stream";
import {promisify} from "util";
const asyncPipeline = promisify(pipeline);
await asyncPipeline(
fileData.fileStream,
fs.createWriteStream(
path.join(assetsPath, fileName),
{
flags: "wx"
}
)
);
My questions:
It does work but I'm not sure if I need to do something extra, for instance, to close a stream manually, or the default
true
-value ofautoClose
does it for me automatically?How can I ensure that the
WriteStream
is closed?