Function: stream()
> stream(source, options?): StreamResponse
Defined in: http/src/stream.ts:69
Wrap a byte source as a streaming response for a route handler to return.
ts
const { record, stream: body } = await files.downloadStream(id)
return stream(body, { contentType: record.contentType, contentLength: record.size, filename: record.name })The bytes are never collected in memory: a slow client slows the source (real backpressure), and a client that disconnects destroys it, so no file descriptor or backend socket is leaked.
Parameters
source
options?
StreamOptions = {}