Primate
Guides Responses

Stream binary data

Serve binary data like files or images. Use the stream response.

Serve file

Read and return binary data.

// routes/file.ts
import FileRef from "@rcompat/fs/FileRef";
import response from "primate/response";
import route from "primate/route";

const file = new FileRef("path/to/file.pdf");

route.get(() => response.binary(file));

Serve stream

Response back with the uploaded steam -- Blobs are automatically streamed.

// routes/backstream.ts
import route from "primate/route";

route.post(request => request.body.binary());