Digger is a lightweight download framework that requires only one line of code to complete the file download task.
Based on URLSession, pure Swift language implementation, support chain syntax call, real-time download progress, real-time download speed, breakpoint download.
The user forces the app to be shut down, for example by sliding off the app. Digger can still resume downloading tasks.
- Large file download
- Multi thread Download
- Thread safety
- Breakpoint downloading
- Controllable concurrency
- iOS 8.0+
- Xcode 9.0+
- Swift 4.0+
Add to your Podfile:
pod'Digger'Add to your Cartfile:
github "cornerAnt/Digger"
###Basic: Download a file in the Digger directory under the sandbox's Caches
leturl="http://example.com/digger.mp4"Digger.download(url)Choose different callbacks depending on your needs
Digger.download(url).progress(nil).speed(nil).completion(nil)leturl="http://example.com/digger.mp4"Digger.download(url).progress({(progresss)inprint(progresss.fractionCompleted)}).speed({(speed)inprint(speed)}).completion{(result)inswitch result {case.success(let url):print(url)case.failure(let error):print(error)}}}Config yourself
/// Start the task at once,default is true
DiggerManager.shared.startDownloadImmediately =false
/// maxConcurrentTasksCount,deault is 3
DiggerManager.shared.maxConcurrentTasksCount =4
/// request timeout,deault is 100 DiggerManager.shared.timeout =150
/// allowsCellularAccess,deault is true
DiggerManager.shared.allowsCellularAccess =false
/// loglevel,deault is high
/*
***************DiggerLog****************
file : ExampleController.swift
method : viewDidLoad()
line : [31]:
info : digger log
*/
// If you want to close,set the level to be .none
DiggerManager.shared.logLevel =.none
// MARK:- DiggerCache
/// In the sandbox cactes directory, custom your cache directory
DiggerCache.cachesDirectory ="Directory"
/// Delete all downloaded files
DiggerCache.cleanDownloadFiles()
/// Delete all temporary download files
DiggerCache.cleanDownloadTempFiles()
/// Get the system's available memory size
_ =DiggerCache.systemFreeSize()
/// Get the size of the downloaded file
_ =DiggerCache.downloadedFilesSize()
/// Get the path to all downloaded files
_ =DiggerCache.pathsOfDownloadedfiles
}- Fork
- Commit changes to a branch in your fork
- Push your code and make a pull request
Digger is Copyright (c) 2017 cornerAnt and released as open source under the attached MIT License.

