Skip to content

Instantly share code, notes, and snippets.

@ritch
Created August 1, 2012 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritch/3227103 to your computer and use it in GitHub Desktop.
Save ritch/3227103 to your computer and use it in GitHub Desktop.
Simple file transfer in node
var http = require('http')
, request = require('request')
, fs = require('fs');
var server = http.createServer(function (req, res) {
req.pipe(fs.createWriteStream('my-file.jpg'));
})
.listen(3000)
.on('listening', function () {
fs.createReadStream('my-file.jpg').pipe(request.post('http://localhost:3000'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment