A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/koajs/sendfile below:

koajs/sendfile: basic file-sending utility for koa

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

It does not:

sendfile(context, filename)

You must pass the koa context. filename is the filename of the file.

sendfile returns a promise that resolves to the fs.stat() result of the filename. If sendfile() resolves, that doesn't mean that a response is set - the filename could be a directory. Instead, check if (context.status).

const sendfile = require('koa-sendfile')

app.use(async function (ctx, next) {
  const stats = await sendfile(ctx, '/Users/jong/.bash_profile')
  if (!ctx.status) ctx.throw(404)
})

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4