Structure
FileIO
FileIO is a convenience wrapper around SwiftNIO’s FileSystem for streaming files with a Request to a Response. It handles streaming file chunks to the response body, ETag support and caching and request ranges.struct FileIO
Topics
Instance Methods
func streamFile(at: String, for: Request, chunkSize: Int64, mediaType: HTTPMediaType?, advancedETagComparison: Bool, onCompleted: @Sendable (Result<Void, any Error>) async throws -> Void) async throws -> ResponseGenerates a chunkedResponsefor the specified file. This method respects values in the"ETag"header and is capable of responding304 Not Modifiedif the file in question has not been modified since last served. IfadvancedETagComparisonis set to true, the response will have its ETag field set to a byte-by-byte hash of the requested file. If set to false, a simple ETag consisting of the last modified date and file size will be used. This method will also set the"Content-Type"header automatically if an appropriateMediaTypecan be found for the file’s suffix.
Relationships
Conforms To
Swift.SendableSwift.SendableMetatype