1.0.0 • Published 9 years ago
file-upload-stream v1.0.0
file-upload-stream
Takes a file and streams it to a http server.
var http = require('http')
var fs = require('fs')
module.exports = function (file, opts) {
var req = http.request(opts)
req.on('error', function (err) {
console.log(err)
})
fs.stat(file, function (err, stat) {
if (err) console.error(err)
opts.headers['Content-Length'] = stat.size
fs.createReadStream(file).pipe(req)
})
}
1.0.0
9 years ago