Skip to content

Commit

Permalink
fix: use stream at download example (eggjs#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Jun 1, 2017
1 parent 03326e9 commit 6d5209f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions download/app/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ module.exports = app => {

* download() {
const filePath = path.resolve(this.app.config.static.dir, 'hello.txt');
const buf = fs.readFileSync(filePath, 'utf-8');
this.ctx.attachment('hello.txt');
this.ctx.set('Content-Type', 'application/octet-stream');
this.ctx.body = buf;
this.ctx.body = fs.createReadStream(filePath);
}
}

Expand Down

0 comments on commit 6d5209f

Please sign in to comment.