Skip to content

Express response.attachment

TIP

将 HTTP 响应 Content-Disposition标头字段设置为 "attachment"。

Express
res.attachment([filename])

将 HTTP 响应 Content-Disposition 标头字段设置为 "attachment"。如果给出了 filename,那么它会根据扩展名通过 res.type() 设置 Content-Type,并设置 Content-Disposition "filename=" 参数。

Express
res.attachment()
// Content-Disposition: attachment

res.attachment('path/to/logo.png')
// Content-Disposition: attachment; filename="logo.png"
// Content-Type: image/png