This commit is contained in:
Tj Holowaychuk 2011-05-20 09:15:35 -07:00
parent 1b34fd7efa
commit b9872a278f

View File

@ -1,7 +1,4 @@
// Expose modules in ./support for demo purposes
require.paths.unshift(__dirname + '/../../support');
/**
* Module dependencies.
*/
@ -24,13 +21,15 @@ app.get('/files/:file(*)', function(req, res, next){
, path = __dirname + '/files/' + file;
// either res.download(path) and let
// express handle failures, or provide
// a callback
// a callback as shown below
res.download(path, function(err){
if (err) return next(err);
// the response has invoked .end()
// so you cannnot respond here (of course)
// but the callback is handy for statistics etc.
console.log('transferred %s', path);
}, function(err){
});
});