Skip to content

Commit aa9bcaa

Browse files
committed
add attachment() documentation
1 parent 8530199 commit aa9bcaa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,20 @@ res.clearCookie('fooArray', { path: '/', httpOnly: true }).send()
389389
**NOTE:** The `clearCookie()` method only sets the header. A execution ending method like `send()`, `json()`, etc. must be called to send the response.
390390

391391
### attachment
392+
Sets the HTTP response `Content-Disposition` header field to "attachment". If a `filename` is provided, then the `Content-Type` is set based on the file extension using the `type()` method and the "filename=" parameter is added to the `Content-Disposition` header.
393+
394+
```javascript
395+
res.attachment()
396+
// Content-Disposition: attachment
397+
398+
res.attachment('path/to/logo.png')
399+
// Content-Disposition: attachment; filename="logo.png"
400+
// Content-Type: image/png
401+
```
392402

393403
### download
394404

395405
### sendFile
396-
397406
The `sendFile()` method takes up to three arguments. The first is the file. This is either a local filename (stored within your uploaded lambda code), a reference to a file in S3 (using the `s3://{my-bucket}/{path-to-file}` format), or a JavaScript `Buffer`. You can optionally pass an `options` object using the properties below as well as a callback function `fn(err)` that can handle custom errors or manipulate the response before sending to the client.
398407

399408
| Property | Type | Description | Default |

0 commit comments

Comments
 (0)