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.
Uses file.type for Content-Type and includes X-Content-Type-Options: nosniff.
Uploaded file metadata does not validate the contents. Validate uploaded files before
serving them inline, or set Content-Disposition: attachment on the returned response.
Signature
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