tubule

0.1.3 • Public • Published

tubule - copy files from URI stream

The tubule Node.js module is a Transform stream that uses http or https to get files from URIs written to it. As the files are copied to a local directory, tubule emits the paths of the completed downloads.

Build Status

Usage

To download all images from nodejs.org:

var http = require('http')
  , tubule = require('tubule')
  , cop = require('cop')
  , scrim = require('scrim')
  , dir = '/tmp/tubule-' + Math.floor(Math.random() * (1<<24))

http.get('http://www.nodejs.org', function (res) {
  res
    .pipe(scrim())
    .on('error', console.error)
    .pipe(cop(abs))
    .pipe(tubule(dir))
    .on('error', console.error)
    .pipe(cop(function (uri) { return uri + '\n' }))
    .pipe(process.stdout)
})

function abs (uri) {
  return uri.toString().substr(0,4) === 'http' ? uri : null
}

tubule(dir)

The tubule module exports a single function that returns a Transform stream.

  • dir The target directory to write the files

Installation

Install with npm:

npm install tubule

License

MIT License

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.3
    1
    • latest

Version History

Package Sidebar

Install

npm i tubule

Weekly Downloads

8

Version

0.1.3

License

MIT

Last publish

Collaborators

  • michaelnisi