Created
August 19, 2019 06:22
-
-
Save MelodicCrypter/5b60cf25898e5dcc62e98808d3f31284 to your computer and use it in GitHub Desktop.
A sample of NodeJS Pipe to copy a video file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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