From 4ed44c7a5f2f0ad0c792f3d92141fcaa979a5b9f Mon Sep 17 00:00:00 2001 From: visionmedia Date: Wed, 30 Dec 2009 16:09:35 -0800 Subject: [PATCH] Added Request#download() --- lib/express/request.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/express/request.js b/lib/express/request.js index 6a50b64f38..7855557cc7 100644 --- a/lib/express/request.js +++ b/lib/express/request.js @@ -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') },