Instance Methodvapor 4.114.1Vapor

readFile(at:chunkSize:offset:byteCount:)

Reads the contents of a file at the supplied path in chunks.

FileIO.swift:422
func readFile(at path: String, chunkSize: Int = NonBlockingFileIO.defaultChunkSize, offset: Int64? = nil, byteCount: Int? = nil) async throws -> FileChunks

Parameters

path

Path to file on the disk.

chunkSize

Maximum size for the file data chunks.

offset

The offset to start reading from.

byteCount

The number of bytes to read from the file. If nil, the file will be read to the end.

Returns

FileChunks containing the file data chunks.

for try await chunk in try await req.fileio.readFile(at: “/path/to/file.txt”) { print(“chunk: (data)”) }