TypedResults.File Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue) |
Writes the byte-array content to the response. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable). This API is an alias for Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue). |
File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean) |
Writes the specified Stream to the response. This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable). This API is an alias for Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean). |
File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)
- Source:
- TypedResults.cs
Writes the byte-array content to the response.
This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).
This API is an alias for Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue).
public static Microsoft.AspNetCore.Http.HttpResults.FileContentHttpResult File (byte[] fileContents, string? contentType = default, string? fileDownloadName = default, bool enableRangeProcessing = false, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default);
static member File : byte[] * string * string * bool * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue -> Microsoft.AspNetCore.Http.HttpResults.FileContentHttpResult
Public Shared Function File (fileContents As Byte(), Optional contentType As String = Nothing, Optional fileDownloadName As String = Nothing, Optional enableRangeProcessing As Boolean = false, Optional lastModified As Nullable(Of DateTimeOffset) = Nothing, Optional entityTag As EntityTagHeaderValue = Nothing) As FileContentHttpResult
Parameters
- fileContents
- Byte[]
The file contents.
- contentType
- String
The Content-Type of the file.
- fileDownloadName
- String
The suggested file name.
- enableRangeProcessing
- Boolean
Set to true
to enable range requests processing.
- lastModified
- Nullable<DateTimeOffset>
The DateTimeOffset of when the file was last modified.
- entityTag
- EntityTagHeaderValue
The EntityTagHeaderValue associated with the file.
Returns
The created FileContentHttpResult for the response.
Applies to
File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)
- Source:
- TypedResults.cs
Writes the specified Stream to the response.
This supports range requests (Status206PartialContent or Status416RangeNotSatisfiable if the range is not satisfiable).
This API is an alias for Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean).
public static Microsoft.AspNetCore.Http.HttpResults.FileStreamHttpResult File (System.IO.Stream fileStream, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member File : System.IO.Stream * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.HttpResults.FileStreamHttpResult
Public Shared Function File (fileStream As Stream, Optional contentType As String = Nothing, Optional fileDownloadName As String = Nothing, Optional lastModified As Nullable(Of DateTimeOffset) = Nothing, Optional entityTag As EntityTagHeaderValue = Nothing, Optional enableRangeProcessing As Boolean = false) As FileStreamHttpResult
Parameters
- contentType
- String
The Content-Type of the file.
- fileDownloadName
- String
The file name to be used in the Content-Disposition
header.
- lastModified
- Nullable<DateTimeOffset>
The DateTimeOffset of when the file was last modified.
Used to configure the Last-Modified
response header and perform conditional range requests.
- entityTag
- EntityTagHeaderValue
The EntityTagHeaderValue to be configure the ETag
response header
and perform conditional requests.
- enableRangeProcessing
- Boolean
Set to true
to enable range requests processing.
Returns
The created FileStreamHttpResult for the response.
Remarks
The fileStream
parameter is disposed after the response is sent.