Downloads a file with xhr, report progress and send the file to the user.
$ component install yields/download
You can run the example with $ make example and then $ serve . && open http://localhost:300/.
var Download = require('download')
, Progress = require('progress');
var download = new Download('somefile');
var progress = new Progress();
doument.body.appendChild(progress.el);
progress.update(0);
download.on('progress', function(e){
progress.update(e.percent);
});
download.end(function(err, req){
if (err) throw err;
location.pathname = '/somefile';
});Create a new Download with filepath.
Abort the request.
Start the download and invoke fn(err, req), at this point you should just do location.pathname = '/somefile'.
MIT