Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-sendfile

Package Overview
Dependencies
Maintainers
9
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-sendfile

basic file-sending utility for koa

  • 1.1.2
  • latest-1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
817
decreased by-52.86%
Maintainers
9
Weekly downloads
 
Created
Source

koa sendfile

NPM version Build status Test coverage Dependency Status License Downloads

Basic file-sending utility for koa. It does the following:

  • Check if a file exists
  • Set content-length, content-type, and last-modified headers
  • 304 based on last-modified
  • Handle HEAD requests

It does not:

  • Check for malicious paths or hidden files
  • Support directory indexes
  • Cache control
  • OPTIONS method

API

var stats = yield* sendfile.call(this, filename)

You must pass this as the context. filename is the filename of the file.

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).

var sendfile = require('koa-sendfile')

app.use(function* (next) {
  var stats = yield* sendfile.call(this, '/Users/jong/.bash_profile')
  if (!this.status) this.throw(404)
})

FAQs

Package last updated on 12 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc