Skip to content

Structure

FileIO

FileIO is a convenience wrapper around SwiftNIO’s NonBlockingFileIO.
struct FileIO

Overview

It can read files, both in their entirety and chunked.

req.fileio.readFile(at: "/path/to/file.txt") { chunk in
    print(chunk) // part of file
}

req.fileio.collectFile(at: "/path/to/file.txt").map { file in
    print(file) // entire file
}

It can also create streaming HTTP responses.

app.get("file-stream") { req -> Response in
    return req.fileio.streamFile(at: "/path/to/file.txt", for: req)
}

Streaming file responses respect E-Tag headers present in the request.

Topics

Structures

  • struct FileChunks
    Wrapper around NIOFileSystem.FileChunks. This can be removed once NIOFileSystem reaches a stable API.

Instance Methods

Relationships

Conforms To

  • Swift.Sendable
  • Swift.SendableMetatype