Created
August 1, 2012 14:03
-
-
Save ritch/3227103 to your computer and use it in GitHub Desktop.
Simple file transfer in node
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
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