/node-curl-download

downloader module for node.js

Primary LanguageJavaScript

Node.js Curl Downloader

Download any file without blocking your server using the power of curl.

forked from node-CurlDownloader and rewrited in coffee-script.

Download and install

Install through NPM

npm install curl-download

OR

Example usage in coffee

# import download
Download = require 'download'

# new download instance
dl = new Download(
  'http://code.jquery.com/jquery-1.11.0.min.js',
  'tmp/jquery-1.11.0.min.js'
  )

# when progress
dl.on 'progress', (progress)->
  console.log "#{progress}%"

  return

# when end
dl.on 'end', (code)->
  # when success
  if code == 0
    console.log "finished successfully"

  # when fail
  else
    console.log "finished unsuccessfully"

  process.exit(code)

  return

# start download
dl.start()

Example usage in javascript

var Download, dl;

Download = require('download');

dl = new Download('http://code.jquery.com/jquery-1.11.0.min.js', 'tmp/jquery-1.11.0.min.js');

dl.on('progress', function(progress) {
  console.log("" + progress + "%");
});

dl.on('end', function(code) {
  if (code === 0) {
    console.log("finished successfully");
  } else {
    console.log("finished unsuccessfully");
  }
  process.exit(code);
});

dl.start();