file-upload-stream

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i file-upload-stream

Weekly Downloads

4

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jekrb