covenix / FileResponse
Class: FileResponse
Defined in: src/file-response.ts:41
A non-JSON response: a binary body (a Uint8Array/Buffer or a Readable stream) that covenix streams to the client, setting Content-Type and Content-Disposition and skipping JSON serialization and response validation. Return one from a handler (typically alongside @ReturnsFile).
Example
@Get('{id}/export')
@ReturnsFile(200, { contentType: 'text/csv' })
export(@Param('id') id: string): FileResponse {
return new FileResponse(Buffer.from(csv), {
contentType: 'text/csv',
filename: `user-${id}.csv`,
});
}Extends
Constructors
Constructor
new FileResponse(
body,options?):FileResponse
Defined in: src/file-response.ts:51
Parameters
body
Uint8Array<ArrayBufferLike> | Readable
options?
FileResponseOptions = {}
Returns
FileResponse
Overrides
Properties
body
readonlybody:Uint8Array<ArrayBufferLike> |Readable
Defined in: src/file-response.ts:43
The response body — raw bytes or a readable stream.
contentType
readonlycontentType:string|undefined
Defined in: src/file-response.ts:45
Content-Type for the response, if set.
cookies
readonlycookies:ResponseCookie[] |undefined
Defined in: src/response.ts:63
Cookies to set (each its own Set-Cookie), if any.
Inherited from
disposition
readonlydisposition:"inline"|"attachment"|undefined
Defined in: src/file-response.ts:49
Content-Disposition type ('inline'/'attachment'), if set.
filename
readonlyfilename:string|undefined
Defined in: src/file-response.ts:47
Download filename for Content-Disposition, if set.
headers
readonlyheaders:Record<string,HeaderValue> |undefined
Defined in: src/response.ts:61
Extra response headers, if set.
Inherited from
status
readonlystatus:number|undefined
Defined in: src/response.ts:59
Explicit HTTP status, if set.
Inherited from
Methods
fromPath()
staticfromPath(path,options?):FileResponse
Defined in: src/file-response.ts:60
Builds a FileResponse that streams the file at path from disk.
Parameters
path
string
options?
Returns
FileResponse
