및 라이브러리를 만들트림
const { Readable } = require("stream")
const readable = Readable.from(["input string"])
readable.on("data", (chunk) => {
console.log(chunk) // will be called once with `"input string"`
})
및 라이브러리 스트림 작성 파일
const readFile: InstanceType<typeof stream.Readable> = new stream.Readable({
read() {
return true
}
})
readFile
.pipe(fs.createWriteStream(`${process.env.IMG_DIR}/${Date.now().toString()}-${file.originalname}`))
.on('finish', Promise.resolve)
.on('error', Promise.reject)