1.0.0 • Published 9 years ago

file-upload-stream v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

file-upload-stream

js-standard-style

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)
  })
}