Skip to content

Commit c0e5dc1

Browse files
committed
examples: demonstrate sub directory download
1 parent b5121a6 commit c0e5dc1

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* milk
2+
* eggs
3+
* bread

examples/downloads/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ var path = require('path');
77
var app = module.exports = express();
88

99
app.get('/', function(req, res){
10-
res.send('<ul>'
11-
+ '<li>Download <a href="/files/amazing.txt">amazing.txt</a>.</li>'
12-
+ '<li>Download <a href="/files/missing.txt">missing.txt</a>.</li>'
13-
+ '<li>Download <a href="/files/CCTV大赛上海分赛区.txt">CCTV大赛上海分赛区.txt</a>.</li>'
14-
+ '</ul>');
10+
res.send('<ul>' +
11+
'<li>Download <a href="/files/notes/groceries.txt">notes/groceries.txt</a>.</li>' +
12+
'<li>Download <a href="/files/amazing.txt">amazing.txt</a>.</li>' +
13+
'<li>Download <a href="/files/missing.txt">missing.txt</a>.</li>' +
14+
'<li>Download <a href="/files/CCTV大赛上海分赛区.txt">CCTV大赛上海分赛区.txt</a>.</li>' +
15+
'</ul>')
1516
});
1617

1718
// /files/* is accessed via req.params[0]

test/acceptance/downloads.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ describe('downloads', function(){
1111
})
1212
})
1313

14+
describe('GET /files/notes/groceries.txt', function () {
15+
it('should have a download header', function (done) {
16+
request(app)
17+
.get('/files/notes/groceries.txt')
18+
.expect('Content-Disposition', 'attachment; filename="groceries.txt"')
19+
.expect(200, done)
20+
})
21+
})
22+
1423
describe('GET /files/amazing.txt', function(){
1524
it('should have a download header', function(done){
1625
request(app)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy