Results.File 方法

定義

多載

File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

將位元組陣列內容寫入回應。

這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。

此 API 是 的 Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue) 別名。

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

將指定的 Stream 寫入回應。

這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。

此 API 是 的 Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean) 別名。

File(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

將位於指定 path 位置的 檔案寫入回應。

這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。

File(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue)

將位元組陣列內容寫入回應。

這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。

此 API 是 的 Bytes(Byte[], String, String, Boolean, Nullable<DateTimeOffset>, EntityTagHeaderValue) 別名。

public static Microsoft.AspNetCore.Http.IResult 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.IResult
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 IResult

參數

fileContents
Byte[]

檔案內容。

contentType
String

檔案的 Content-Type。

fileDownloadName
String

建議的檔案名。

enableRangeProcessing
Boolean

設定為 true 以啟用範圍要求處理。

lastModified
Nullable<DateTimeOffset>

DateTimeOffset上次修改檔案時的 。

entityTag
EntityTagHeaderValue

EntityTagHeaderValue與檔案相關聯的 。

傳回

為回應建立 IResult 的 。

適用於

File(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

將指定的 Stream 寫入回應。

這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。

此 API 是 的 Stream(Stream, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean) 別名。

public static Microsoft.AspNetCore.Http.IResult 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.IResult
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 IResult

參數

fileStream
Stream

Stream具有檔案內容的 。

contentType
String

檔案的 Content-Type。

fileDownloadName
String

要用於標頭的 Content-Disposition 檔案名。

lastModified
Nullable<DateTimeOffset>

DateTimeOffset上次修改檔案時的 。 用來設定 Last-Modified 回應標頭並執行條件式範圍要求。

entityTag
EntityTagHeaderValue

EntityTagHeaderValue要設定 ETag 回應標頭並執行條件式要求的 。

enableRangeProcessing
Boolean

設定為 true 以啟用範圍要求處理。

傳回

為回應建立 IResult 的 。

備註

在傳送回應之後,會 fileStream 處置 參數。

適用於

File(String, String, String, Nullable<DateTimeOffset>, EntityTagHeaderValue, Boolean)

將位於指定 path 位置的 檔案寫入回應。

這支援範圍要求 (Status206PartialContent ,或者 Status416RangeNotSatisfiable 範圍無法滿足) 。

public static Microsoft.AspNetCore.Http.IResult File (string path, string? contentType = default, string? fileDownloadName = default, DateTimeOffset? lastModified = default, Microsoft.Net.Http.Headers.EntityTagHeaderValue? entityTag = default, bool enableRangeProcessing = false);
static member File : string * string * string * Nullable<DateTimeOffset> * Microsoft.Net.Http.Headers.EntityTagHeaderValue * bool -> Microsoft.AspNetCore.Http.IResult
Public Shared Function File (path As String, 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 IResult

參數

path
String

檔案的路徑。 若未進行根目錄,則會解析相對於 WebRootFileProvider 的路徑。

contentType
String

檔案的 Content-Type。

fileDownloadName
String

建議的檔案名。

lastModified
Nullable<DateTimeOffset>

DateTimeOffset上次修改檔案時的 。

entityTag
EntityTagHeaderValue

EntityTagHeaderValue與檔案相關聯的 。

enableRangeProcessing
Boolean

設定為 true 以啟用範圍要求處理。

傳回

為回應建立 IResult 的 。

適用於