Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / index / file

Function: file()

file(path, options?): Promise<void>

Defined in: helpers/response.ts:361

Stream a file from disk as the response. Defaults to attachment disposition (a browser download) with the file's basename; override either via options.

Parameters

path

string

Absolute or working-directory-relative path to the file.

options?

Optional filename (download name) and disposition ("attachment" to download, "inline" to display in the browser).

filename?

string

disposition?

"inline" | "attachment"

Returns

Promise<void>

Throws

If no file exists at path.

Example

await file('storage/invoices/2026-07.pdf');                          // download as "2026-07.pdf"
await file('storage/report.pdf', { filename: 'Q3-Report.pdf' });     // download, renamed
await file('storage/preview.pdf', { disposition: 'inline' });        // view in-browser