Instance Method
readFile(at:chunkSize:onRead:)
Reads the contents of a file at the supplied path in chunks.
@preconcurrency func readFile(at path: String, chunkSize: Int = NonBlockingFileIO.defaultChunkSize, onRead: @escaping @Sendable (ByteBuffer) -> EventLoopFuture<Void>) -> EventLoopFuture<Void>
Parameters
pathPath to file on the disk.
chunkSizeMaximum size for the file data chunks.
onReadClosure to be called sequentially for each file data chunk.
Return Value
Future that will complete when the file read is finished.
Discussion
try req.fileio.readFile(at: "/path/to/file.txt") { chunk in
print("chunk: \(data)")
}.wait()