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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* milk
2+
* eggs
3+
* bread

examples/downloads/index.js

+6-5
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

+9
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)