download-to-file
Download a file to disk programmatically
Last updated 2 years ago by watson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install download-to-file 
SYNC missed versions from official npm registry.

download-to-file

Download a file to disk programmatically.

Build status js-standard-style

Installation

npm install download-to-file --save

Usage

var download = require('download-to-file')

console.log('Downloading to /tmp/example.html')
download('http://example.com/', '/tmp/example.html', function (err, filepath) {
  if (err) throw err
  console.log('Download finished:', filepath)
})

API

download(url, filepath, callback)

Will download the content of the given url and store it in a file specified by filepath. When done, the callback will be called with an optional error object as the first argument and the filepath as the second argument.

If the server does not return a 200 HTTP status code, the callback will be called with an error and the file will not be stored on disk.

License

MIT

Current Tags

  • 2.1.0                                ...           latest (2 years ago)

3 Versions

  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 8
Dependencies (2)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |