Stream write file

PHOTO EMBED

Wed Aug 10 2022 09:45:44 GMT+0000 (Coordinated Universal Time)

Saved by @dio_dev #javascript #nodejs

const file = bucket.file(`${folderName}/${fileName}`)
const passThroughStream = new stream.PassThrough()
passThroughStream.write(fileTitle)
passThroughStream.write(fileHeader)
passThroughStream.write(convertArrayToCSV(accounts.map(mapRecords)))
passThroughStream.end()

passThroughStream
  .pipe(file.createWriteStream())
  .on('error', (err) => {
  console.error(makeLogEntry(err))
})
  .on('finish', () => {
  console.log('writed')
})
content_copyCOPY