Permalink
Browse files

docs

  • Loading branch information...
1 parent b9872a2 commit 286c92b13b6952181722123a3406f39e06e1f23d @tj tj committed May 20, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 examples/downloads/app.js
View
@@ -23,13 +23,18 @@ app.get('/files/:file(*)', function(req, res, next){
// express handle failures, or provide
// a callback as shown below
res.download(path, function(err){
+ // if an error occurs in this callback
+ // the file most likely does not exist,
+ // and it's safe to respond or next(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.
+
+ // the file has been transferred, do not respond
+ // from here, though you may use this callback
+ // for stats etc.
console.log('transferred %s', path);
}, function(err){
-
+ // this second optional callback is used when
+ // an error occurs during transmission
});
});

0 comments on commit 286c92b

Please sign in to comment.