Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Created March 12, 2013 06:18
Show Gist options
  • Select an option

  • Save mikermcneil/5140740 to your computer and use it in GitHub Desktop.

Select an option

Save mikermcneil/5140740 to your computer and use it in GitHub Desktop.
stream from a url to a file
var fs = require('fs');
var knox = require('knox');
var request = require('request');
var uri = "https://lh4.ggpht.com/N5f6FA5zPjrTH-UggaFLstYSO1za-01CbsO17ZwkghtF0k9TSzWcnCn4bybCDeIOP4cu=w124";
// Open download stream from google
var downStream = request(uri);
// Open temp file ("upload" stream)
var tempFile = fs.createWriteStream('stupidTempFile.png');
// Pipe downstream to upstream
downStream.pipe(tempFile);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment