remix/response/file · FunctionView Source
createFileResponse
Summary
Creates a file Response
with full HTTP semantics including ETags, Last-Modified, conditional requests, and Range support.
Accepts both native File objects and
import('@remix-run/lazy-file').LazyFile values.
Signature
function createFileResponse<file extends FileLike>(
file: file,
request: Request,
options: FileResponseOptions<file>,
): Promise<Response>;
Example
import { createFileResponse } from "remix/response/file";
import { openLazyFile } from "remix/fs";
let lazyFile = openLazyFile("./public/image.jpg");
return createFileResponse(lazyFile, request, {
cacheControl: "public, max-age=3600",
});
Parameters
file
request
The request object
options
Configuration options
Returns
A Response object containing the file