Skip to content

Commit a8221bf

Browse files
committed
badges
1 parent 9a8bd90 commit a8221bf

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

README.md LICENSE

-36
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
2-
# koa sendfile
3-
4-
Basic file-sending utility for koa. It does the following:
5-
6-
- Check if a file exists
7-
- Set content-length, content-type, and last-modified headers
8-
- 304 based on last-modified
9-
- Handle HEAD requests
10-
11-
It does not:
12-
13-
- Check for malicious paths or hidden files
14-
- Support directory indexes
15-
- Cache control
16-
- OPTIONS method
17-
18-
## API
19-
20-
### var stats = yield* sendfile.call(this, filename)
21-
22-
You must pass `this` as the context. `filename` is the filename of the file.
23-
24-
`stats` is the `fs.stat()` result of the filename. If `stats` exists, that doesn't mean that a response is set - the filename could be a directory. Instead, check `if (this.status)`.
25-
26-
```js
27-
var sendfile = require('koa-sendfile')
28-
29-
app.use(function* (next) {
30-
var stats = yield* sendfile.call(this, '/Users/jong/.bash_profile')
31-
if (!this.status) this.throw(404)
32-
})
33-
```
34-
35-
## License
36-
371
The MIT License (MIT)
382

393
Copyright (c) 2014 Jonathan Ong [email protected]

0 commit comments

Comments
 (0)