Skip to content

Instantly share code, notes, and snippets.

@MelodicCrypter
Created August 19, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelodicCrypter/5b60cf25898e5dcc62e98808d3f31284 to your computer and use it in GitHub Desktop.
Save MelodicCrypter/5b60cf25898e5dcc62e98808d3f31284 to your computer and use it in GitHub Desktop.
A sample of NodeJS Pipe to copy a video file.
const { createReadStream, createWriteStream } = require('fs');
const readStream = createReadStream(__dirname+'/powder-day.mp4');
const writeStream = createWriteStream(__dirname+'/copy.mp4' );
// Pipe, will handle backpressure automatically
readStream
.pipe(writeStream)
.on('error', console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment