1.0.0 • Published 8 years ago

tmp-dl v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

tmp-dl

Version Build Status Code Climate Coveralls npm License

Download a remote file to a temporary location.

Installation

npm install --save tmp-dl

Usage

var temporaryDownload = require('tmp-dl');

var url = 'http://www.example.com/some-awesome-image.jpg';

temporaryDownload(url)
  .then(function(file) {
    // remote file downloaded to temporary location  
  })
  .catch(function(err) {
    // something went wrong
  });  

tmp-dl will return a promise. The promise will resolve once the remote file has been downloaded. Any errors that occur during the download of the file, or the creation of the temporary location will cause the promise to reject.

The resolved file object will be a Vinyl file:

var temporaryDownload = require('tmp-dl');

var url = 'http://www.example.com/some-awesome-image.jpg';

temporaryDownload(url)
  .then(function(file) {
    var savedFilePath = file.path;

    // do something with saved file path...       
  });

Check out the documentation for Vinyl to view the methods / properties available for the resolved file object.