FileDownloadDelegate
public final class FileDownloadDelegate : HTTPClientResponseDelegate
Handles a streaming download to a given file path, allowing headers and progress to be reported.
-
The response type for this delegate: the total count of bytes as reported by the response “Content-Length” header (if available) and the count of bytes downloaded.
See moreDeclaration
Swift
public struct Progress -
Undocumented
Declaration
Swift
public typealias Response = Progress -
Initializes a new file download delegate.
Declaration
Swift
public init( path: String, pool: NIOThreadPool = NIOThreadPool(numberOfThreads: 1), reportHead: ((HTTPResponseHead) -> Void)? = nil, reportProgress: ((Progress) -> Void)? = nil ) throwsParameters
pathPath to a file you’d like to write the download to.
poolA thread pool to use for asynchronous file I/O.
reportHeadA closure called when the response head is available.
reportProgressA closure called when a body chunk has been downloaded, with the total byte count and download byte count passed to it as arguments. The callbacks will be invoked in the same threading context that the delegate itself is invoked, as controlled by
EventLoopPreference. -
Declaration
Swift
public func didReceiveHead( task: HTTPClient.Task<Response>, _ head: HTTPResponseHead ) -> EventLoopFuture<Void> -
Declaration
Swift
public func didReceiveBodyPart( task: HTTPClient.Task<Response>, _ buffer: ByteBuffer ) -> EventLoopFuture<Void> -
Declaration
Swift
public func didReceiveError(task: HTTPClient.Task<Progress>, _ error: Error) -
Declaration
Swift
public func didFinishRequest(task: HTTPClient.Task<Response>) throws -> Response
View on GitHub
Install in Dash
FileDownloadDelegate Class Reference