DMSwift

public class DMSwift

DMSwift provides a simple and efficient way to download files. It can simultaneously download a large number of files, monitors the progress of downloading, concurrently post-process downloaded files, supports logging, has a flexible configuration and easy to use API.

  • Download progress delegate.

    There is no reason to declare delegate as weak, as only Value Types are passed. also due to weak, delegates do not work when the Downloader class is declared locally.

    Declaration

    Swift

    public weak var downloadProgressDelegate: DownloaderProgressDelegate?
  • Post-process delegate

    There is no reason to declare delegate as weak, as only Value Types are passed. also due to weak, delegates do not work when the Downloader class is declared locally.

    Declaration

    Swift

    public weak var postProcessDelegate: PostProcessDelegate?
  • Informs when downloaded size or total files size changes.

    Declaration

    Swift

    public var onDownloadUpdateSize: ((_ progress: DMSwiftTypealias.DownloadedSizeProgress) -> Void)?
  • Informs on changes in download task count progress.

    Declaration

    Swift

    public var onDownloadUpdateTaskCount: ((_ progress: DMSwiftTypealias.TaskCountProgress) -> Void)?
  • Informs when download operations started.

    Declaration

    Swift

    public var onDownloadStarted: (() -> Void)?
  • Informs when all download operations finished.

    Declaration

    Swift

    public var onDownloadComplete: (() -> Void)?
  • Informs when downloaded operations finished and some of them have errors.

    Declaration

    Swift

    public var onDownloadCompletedWithError: ((_ tasks: [DMSwiftTypealias.Download.FailedTask]) -> Void)?
  • Informs when post-processing operations started.

    Declaration

    Swift

    public var onPostProcessStarted: (() -> Void)?
  • Informs when all post-processing operations finished.

    Declaration

    Swift

    public var onPostProcessCompleted: (() -> Void)?
  • Informs when post-processing operations finished and some of them have errors.

    Declaration

    Swift

    public var onProcessCompletedWithError: ((_ tasks: [DMSwiftTypealias.PostProcess.FailedTask]) -> Void)?
  • Informs on changes in post-process operations count progress.

    Declaration

    Swift

    public var onPostProcessUpdateTaskCount: ((_ progress: DMSwiftTypealias.TaskCountProgress) -> Void)?
  • Customizable configuration.

    Declaration

    Swift

    public var configuration: DMSwiftConfiguration { get set }
  • File storage manager.

    Declaration

    Swift

    public var fileStorage: FileStorage { get set }
  • Download queue.

    Declaration

    Swift

    var downloadQueue: DownloadQueue
  • Post-process queue.

    Declaration

    Swift

    var postProcessQueue: PostProcessQueue
  • Logging level.

    Declaration

    Swift

    var logLevel: LogLevel { get set }
  • Initiates with default configuration.

    Declaration

    Swift

    public init()
  • Initiates with required parameters.

    Declaration

    Swift

    public init(path: String? = nil,
                postProcessings: [PostProcessing] = [],
                configuration: DMSwiftConfiguration = DefaultDMSwiftConfiguration(),
                fileStorageConfiguration: FileStorageConfiguration = DefaultFileStorageConfiguration(),
                logLevel: LogLevel = .none)

    Parameters

    path

    Specifies the path where files will be saved.

    postProcessings

    List of post-processes for downloaded files.

    configuration

    Configuration.

    fileStorageConfiguration

    Configuration that used for FileStorageManager.

    logLevel

    Logging level.

  • Initiates with required parameters.

    Declaration

    Swift

    public convenience init(path: String?)

    Parameters

    path

    Specifies the path where files will be saved.

  • Prepares files for download, removes duplicates from the provided list of requests.

    if the file is present locally, forceDownload == true or the request is already in the download queue, then it will not be added to download queue.

    Declaration

    Swift

    func prepareDownload(_ requests: [URLRequestTestable], forceDownload: Bool = false, completion: ((_ fileData: DMSwiftTypealias.Download.FileData) -> Void)? = nil)

    Parameters

    requests

    Requests for remote files.

    forceDownload

    Whether to force download, even if the file with the same name located in the device storage.

    completion

    Completion handler called when one of the download operations is finish in the queue.