1.0.0 • Published 8 years ago
tmp-dl v1.0.0
tmp-dl
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.
1.0.0
8 years ago