pub struct FileResult { /* private fields */ }Expand description
A file response — ASP.NET Core’s PhysicalFile(...) / File(...) /
Results.File(...).
The host streams the source and fills in the HTTP metadata: Content-Length,
ETag / Last-Modified validators, Accept-Ranges and Range handling
(206 / 416), plus conditional requests (304). Files opened from a path
derive their validators from size and mtime; streams become conditional when
an entity_tag or
last_modified is supplied.
Implementations§
Source§impl FileResult
impl FileResult
Sourcepub fn path(path: impl Into<PathBuf>) -> FileResult
pub fn path(path: impl Into<PathBuf>) -> FileResult
Send the file at path (ASP.NET Core’s PhysicalFile).
Sourcepub fn stream(reader: impl AsyncRead + Send + Unpin + 'static) -> FileResult
pub fn stream(reader: impl AsyncRead + Send + Unpin + 'static) -> FileResult
Send an async reader of unknown length (chunked, no Range).
Sourcepub fn seekable_stream(
reader: impl AsyncRead + AsyncSeek + Send + Unpin + 'static,
len: u64,
) -> FileResult
pub fn seekable_stream( reader: impl AsyncRead + AsyncSeek + Send + Unpin + 'static, len: u64, ) -> FileResult
Send an async reader of known length that supports seeking, so clients
can resume and cache (Content-Length, Range).
Sourcepub fn with_body(body: FileBody) -> FileResult
pub fn with_body(body: FileBody) -> FileResult
Send a fully-specified FileBody.
Sourcepub fn content_type(self, content_type: impl Into<String>) -> FileResult
pub fn content_type(self, content_type: impl Into<String>) -> FileResult
Override the media type instead of deriving it from the extension.
Sourcepub fn download_name(self, file_name: impl Into<String>) -> FileResult
pub fn download_name(self, file_name: impl Into<String>) -> FileResult
Send the file as a download named file_name.
Sourcepub fn inline_name(self, file_name: impl Into<String>) -> FileResult
pub fn inline_name(self, file_name: impl Into<String>) -> FileResult
Present the file inline under file_name.
Sourcepub fn enable_range_processing(self, enabled: bool) -> FileResult
pub fn enable_range_processing(self, enabled: bool) -> FileResult
Enable or disable Range processing for the file source.
Sourcepub fn last_modified(self, last_modified: SystemTime) -> FileResult
pub fn last_modified(self, last_modified: SystemTime) -> FileResult
Advertise an explicit Last-Modified (required for a stream to support
If-Modified-Since).
Sourcepub fn entity_tag(self, entity_tag: impl Into<String>) -> FileResult
pub fn entity_tag(self, entity_tag: impl Into<String>) -> FileResult
Advertise an explicit ETag (required for a stream to support
If-None-Match).
Sourcepub fn status(self, status: u16) -> FileResult
pub fn status(self, status: u16) -> FileResult
Override the HTTP status.