* download * @param {String} filepath * @param {String} filename
(filepath, filename = path.basename(filepath))
| 301 | * @param {String} filename |
| 302 | */ |
| 303 | download(filepath, filename = path.basename(filepath)) { |
| 304 | assert(filepath, 'filepath can not be empty'); |
| 305 | const contentType = this.response.get('Content-Type'); |
| 306 | if (!contentType) { |
| 307 | this.type = path.extname(filename); |
| 308 | } |
| 309 | const contentDisposition = this.response.get('Content-Disposition'); |
| 310 | if (!contentDisposition) { |
| 311 | this.attachment(filename); |
| 312 | } |
| 313 | const stream = fs.createReadStream(filepath); |
| 314 | this.body = stream; |
| 315 | onFinished(this.res, () => { |
| 316 | destroy(stream); |
| 317 | }); |
| 318 | return false; |
| 319 | } |
| 320 | }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…