Skip to content

Commit

Permalink
examples: use updated res.download in example
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Mar 25, 2022
1 parent 03dc367 commit 10b9b50
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 1 addition & 4 deletions examples/downloads/index.js
Expand Up @@ -6,7 +6,6 @@

var express = require('../../');
var path = require('path');
var resolvePath = require('resolve-path')

var app = module.exports = express();

Expand All @@ -25,9 +24,7 @@ app.get('/', function(req, res){
// /files/* is accessed via req.params[0]
// but here we name it :file
app.get('/files/:file(*)', function(req, res, next){
var filePath = resolvePath(FILES_DIR, req.params.file)

res.download(filePath, function (err) {
res.download(req.params.file, { root: FILES_DIR }, function (err) {
if (!err) return; // file sent
if (err.status !== 404) return next(err); // non-404 error
// file for download not found
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -75,7 +75,6 @@
"multiparty": "4.2.3",
"nyc": "15.1.0",
"pbkdf2-password": "1.2.1",
"resolve-path": "1.4.0",
"supertest": "6.2.2",
"vhost": "~3.0.2"
},
Expand Down

0 comments on commit 10b9b50

Please sign in to comment.