file-upload-stream
v1.0.0
Published
Takes a file and streams to a http server.
Downloads
37
Readme
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)
})
}