DownloadStatus

extension DownloadStatus
  • Initialize a DownloadStatus

    Declaration

    Swift

    public convenience init(downloadId: UInt64,
                            state: DownloadState,
                            error: DownloadError?,
                            totalBytes: UInt64?,
                            receivedBytes: UInt64,
                            transferredBytes: UInt64,
                            downloadOptions: DownloadOptions,
                            httpResult: Result<HttpResponseData, HttpRequestError>?)

    Parameters

    downloadId

    Download id which was created by download request.

    state

    State of download request.

    error

    Contains error information in case of failure when state is set to DownloadState.failed.

    totalBytes

    Total amount of bytes to receive. In some cases this value is unknown until we get final part of the file.

    receivedBytes

    Amount of bytes already received and saved on the disk. Includes previous download attempts for a resumed download.

    transferredBytes

    Amount of bytes received during the current resume attempt. For downloads that weren’t resumed, this value will be the same as receivedBytes.

    downloadOptions

    Download options used to send the download request.

    httpResult

    An optional HTTP result. This field is only set for DownloadState.failed and DownloadState.finished. For .failed expect HttpRequestError to be provided for cases when DownloadErrorCode is NetworkError. For .finished HttpResponseData is set, but with empty data field (since all the data was written to the disk).

  • Convenience to initialize a DownloadStatus when the download state is .pending

    Declaration

    Swift

    public convenience init(error: DownloadError?,
                            totalBytes: UInt64?,
                            downloadOptions: DownloadOptions,
                            httpResult: Result<HttpResponseData, HttpRequestError>?)

    Parameters

    error

    Contains error information in case of failure when state is set to DownloadState.failed.

    totalBytes

    Total amount of bytes to receive. In some cases this value is unknown until we get final part of the file.

    downloadOptions

    Download options used to send the download request.

    httpResult

    An optional HTTP result. This field is only set for DownloadState.failed and DownloadState.finished. For .failed expect HttpRequestError to be provided for cases when DownloadErrorCode is NetworkError. For .finished HttpResponseData is set, but with empty data field (since all the data was written to the disk).

  • HTTP result. This field is only set for DownloadState.failed and DownloadState.finished.

    For .failed expect HttpRequestError to be provided for cases when DownloadErrorCode is NetworkError. And for .finished HttpResponseData is set, but with empty data field (since all the data was written to the disk).

    Declaration

    Swift

    public var httpResult: Result<HttpResponseData, HttpRequestError>? { get }
  • Total amount of bytes to receive. In some cases this value is unknown until we get final part of the file being downloaded.

    Declaration

    Swift

    public var totalBytes: UInt64? { get }