MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / attachment

Function attachment

packages/res/src/download.ts:58–66  ·  view source on GitHub ↗
(
  res: Response
)

Source from the content-addressed store, hash-verified

56}
57
58export const attachment = <Response extends Pick<S, 'getHeader' | 'setHeader'> = Pick<S, 'getHeader' | 'setHeader'>>(
59 res: Response
60) => (filename?: string): Response => {
61 if (filename) setContentType(res)(extname(filename))
62
63 setHeader(res)('Content-Disposition', contentDisposition(filename))
64
65 return res
66}

Callers 2

extendMiddlewareFunction · 0.90
res.test.tsFile · 0.90

Calls 3

setContentTypeFunction · 0.90
setHeaderFunction · 0.90
contentDispositionFunction · 0.90

Tested by

no test coverage detected