Skip to content

Commit

Permalink
Added Request#download()
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Dec 31, 2009
1 parent 29a14c9 commit 4ed44c7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/express/request.js
Expand Up @@ -211,17 +211,29 @@ exports.Request = Class({
})
},

/**
* Transfer static file at the given _path_ as an attachment.
*
* @param {string} path
* @api public
*/

download: function(path) {
this.attachment(path)
this.sendfile(path)
},

/**
* Set Content-Disposition header to 'attachment',
* with optional _filename_.
* with optional file _path_.
*
* @param {string} filename
* @param {string} path
* @api public
*/

attachment: function(filename) {
this.header('content-disposition', filename ?
'attachment; filename="' + filename + '"' :
attachment: function(path) {
this.header('content-disposition', path ?
'attachment; filename="' + path + '"' :
'attachment')
},

Expand Down

0 comments on commit 4ed44c7

Please sign in to comment.