Skip to content
masterclass Buddy

Express.js · Method

res.attachment

res.attachment() marks an HTTP response as a file attachment. An optional filename sets the download name and the Content-Type from its extension.

Last updated

Syntax

res.attachment([filename])

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • res.type()
  • res.download()
  • res.set()

Source: Response · Express.js 5.x. Checked 2026-11-03.