Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

nodejs stream write file

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)
 
PREVIOUS NEXT
Tagged: #nodejs #stream #write #file
ADD COMMENT
Topic
Name
4+1 =