URLSessionBasedDownloadOperation

public final class URLSessionBasedDownloadOperation : URLSessionBasedNetworkOperation<Download.Response>
extension URLSessionBasedDownloadOperation: DownloadOperation
extension URLSessionBasedDownloadOperation: CustomStringConvertible

Concrete implementation of DownloadOperation backed by a URLSessionDownloadTask.

  • Initializes an operation with a task and destination.

    Declaration

    Swift

    public init(task: URLSessionDownloadTask, destination: @escaping (URL) throws -> URL)

    Parameters

    task

    A backing download task in a suspended state.

    destination

    A block called with the temporary location of the downloaded file on disk. The block must either move or open the file for reading before it returns, otherwise the file gets deleted. The block should return the new location of the file.

  • Declaration

    Swift

    public var response: Download.Response? { get }
  • Declaration

    Swift

    public var numberOfBytesReceived: Int64 { get }
  • Declaration

    Swift

    public var totalNumberOfBytesToReceive: Int64 { get }
  • Declaration

    Swift

    @discardableResult
    public func addCompletionBlock(with queue: DispatchQueue?, _ block: @escaping (Download.Response) -> Void) -> URLSessionBasedDownloadOperation
  • Declaration

    Swift

    @discardableResult
    public func addProgressBlock(with queue: DispatchQueue?, _ block: @escaping (Int64, Int64) -> Void) -> URLSessionBasedDownloadOperation
  • Declaration

    Swift

    public var description: String { get }