Digger is a lightweight download framework that requires only one line of code to complete the file download task

Overview

Version Carthage compatible Version

中文说明

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.

Features:

  • Large file download
  • Multi thread Download
  • Thread safety
  • Breakpoint downloading
  • Controllable concurrency

Requirements"

  • iOS 8.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

Add to your Podfile:

pod 'Digger'

Carthage

Add to your Cartfile:

github "cornerAnt/Digger"

Usage

###Basic: Download a file in the Digger directory under the sandbox's Caches

   let url = "http://example.com/digger.mp4"
   Digger.download(url)

Choose different callbacks depending on your needs

        
  Digger.download(url)
        .progress(nil)
        .speed(nil)
        .completion(nil)
   let url = "http://example.com/digger.mp4"

        Digger.download(url)
            .progress({ (progresss) in
                print(progresss.fractionCompleted)

            })
            .speed({ (speed) in
                print(speed)
            })
            .completion { (result) in
                
                switch 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
}

Contributing

  1. Fork
  2. Commit changes to a branch in your fork
  3. Push your code and make a pull request

License

Digger is Copyright (c) 2017 cornerAnt and released as open source under the attached MIT License.

Comments
  • Uploads

    Uploads

    Hey,

    Just wondering if you'd consider adding an upload functionality with most of the benefits you've currently got when downloading with Digger (resume even when the user quits the app etc)?

    opened by jyounus 9
  • stopAllTasks() not working

    stopAllTasks() not working

    In the example project, I press the top Stop button, but the downloads keep running.

    I also commented NotificationCenter.default.post(name:NSNotification.Name(rawValue: suspendNotificationName), object: ExampleCell.self) but they still keep running. So it might be something in Digger, not in the example project.

    I'm running iOS 11 Simulator.

    opened by alexandrutomescu 1
  • Install from cocoapods not working

    Install from cocoapods not working

    Hi! Great library!

    In Podfile, I added pod 'Digger' under target 'Digger' do, but I'm getting the error

    Analyzing dependencies
    [!] Unable to find a specification for `Digger`
    
    opened by alexandrutomescu 1
  • iOS8崩溃

    iOS8崩溃

    dyld: Symbol not found: _NSURLSessionTaskPriorityDefault Referenced from: /private/var/mobile/Containers/Bundle/Application/******* Expected in: /System/Library/Frameworks/Foundation.framework/Foundation in /private/var/mobile/Containers/Bundle/Application/********** (lldb)

    需要在Digger的Target中添加CFNetwork

    bug 
    opened by seahuai 1
  • 作者你好,看到你的库我很激动

    作者你好,看到你的库我很激动

    之前我也花了一些时间写了一个很你这个库很像的下载器,里面的类名,方法名称,链式调用的特点,都很像,可能这就是缘分吧。本人水平有限,你写得应该会比我好,所以打算使用你的库,但是好像有不满足我的需求。 我需要传入一个urlString数组,然后开启下载,下载的过程中我要得到这组任务的总进度,并且这组任务全部下载完,我在拿到回调做事情处理,也就是一个multiDownload的方法。如果你有兴趣的话,请加入这个功能,或者加我的QQ:176516837,一起讨论

    opened by Danie1s 1
  • Is it possible stop and resume download file ?

    Is it possible stop and resume download file ?

    Hi thanks for great plugin and saved me a lot of time research about downloading file.

    Is it possible resume and stop download ?

    thanks for your replied!

    opened by kristoff2016 0
  • Request - Can you please add existing contributors to grant access to this code's repo?

    Request - Can you please add existing contributors to grant access to this code's repo?

    https://github.com/cornerAnt/Digger/network

    Hi @cornerAnt This is a great library - but colleagues are turned off that it's not been updated in a long time. Please grab the usernames from network that you see fit - and just add them into repo - this will allow Digger to live on. People that have spent the time to do pull request - will have time to fix stuff too.

    I'm finding swiftlint autofix is making the network stuff stop working - I'd be happy to spend time fixing - but if the project is abandoned - less so. Also completely open to suggesting a different repo to use.

    opened by 8secz-johndpope 3
  • Can't change cachesDirectory

    Can't change cachesDirectory

    Anyone else able to change the cachesDirectory? This has no effect:

    DiggerCache.cachesDirectory = "custom_name"

    All downloads end up in a folder called "Digger" no matter what I set.

    opened by jln19 0
  • 'deinitialize()' is unavailable: the default argument to deinitialize(count:) has been removed, please specify the count explicitly

    'deinitialize()' is unavailable: the default argument to deinitialize(count:) has been removed, please specify the count explicitly

    Since upgrading to Swift 5, I get the following errors:

    valuePointer.deinitialize() //'deinitialize()' is unavailable: the default argument to deinitialize(count:) has been removed, please specify the count explicitly

    valuePointer.deallocate(capacity: 1) //'deallocate(capacity:)' is unavailable: Swift currently only supports freeing entire heap blocks, use deallocate() instead

    let message = data.withUnsafeBytes { bytes -> [UInt8] in
                    return Array(UnsafeBufferPointer(start: bytes, count: data.count))
                } //'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead
    

    When can we expect a fix on this? I see it is out of date and needs some maintenance ASAP.

    opened by dutypro 1
  • progress.fractionCompleted is always 1.0

    progress.fractionCompleted is always 1.0

    Digger.download(self.fileurl.absoluteString)
    			.progress { progress in
    				print(progress.fractionCompleted)
    			}
    			.completion { result in
    				switch result {
    				case .success(let url):
    					print(url)
    					
    				case .failure(let error):
    					print(error)
    				}
    			}
    

    Testing on ios 9.1 to 13.

    opened by dzpt 0
Owner
Ant
To be a better man
Ant
4channer - Unofficial 4chan read-only client for iPhone and iPad

4channer An unofficial 4chan read-only client for iPhone and iPad, using the 4ch

ArtichautCosmique 12 Nov 15, 2022
NewsAppTask - News App Task for iOS

NewsAppTask The application is designed to view the news for the last 7 days fro

Mikhail Skuratov 0 Feb 6, 2022
Fizz Buzz is a very simple programming task, asked in software developer job interviews.

FizzBuzz Fizz Buzz is a very simple programming task, asked in software developer job interviews. A typical round of Fizz Buzz can be: Write a program

Allan Garcia 1 Jun 6, 2022
Switch viewcontroller like ios task manager

Kaeru Kaeru can switch ViewController in NavigationController like iOS task manager UI (after iOS 9). Movie Usage You can use HistoryNavigationControl

bannzai 508 Dec 7, 2022
A progressive download manager for Alamofire

ALDownloadManager A progressive download manager for Alamofire (Alamofire下载器) The default support breakpoint continues. Sequential Download(顺序下载 ) Dow

null 48 May 1, 2022
Snap Scraper enables users to download media uploaded to Snapchat's Snap Map using a set of latitude and longitude coordinates.

Snap Scraper Description Snap Scraper is an open source intelligence tool which enables users to download media uploaded to Snapchat's Snap Map using

Dr Richard Matthews 58 Dec 12, 2022
ServiceData is an HTTP networking library written in Swift which can download different types of data.

ServiceData Package Description : ServiceData is an HTTP networking library written in Swift which can download different types of data. Features List

Mubarak Alseif 0 Nov 11, 2021
A modern download manager based on NSURLSession to deal with asynchronous downloading, management and persistence of multiple files.

TWRDownloadManager TWRDownloadManager A modern download manager for iOS (Objective C) based on NSURLSession to deal with asynchronous downloading, man

Michelangelo Chasseur 407 Nov 19, 2022
Native ios app to download tiktoks localy made in swift with SwiftUI

sequoia Native ios app to download tiktoks localy made in swift with SwiftUI without external dependencies. features save video localy view saved vide

fleur 9 Dec 11, 2022
NotionDrive - A swift package that can upload files to Notion.so or download files from Notion.so

NotionDrive NotionDrive is a swift package that can upload files to Notion.so or

Underthestars-zhy 4 Apr 9, 2022
File downloading library for Swift 3

VeloxDownloader About: VeloxDownloader is an easy to use,elegant, native yet powerfull download library made with Swift 3. It abstracts all the comple

Nitin Sharma 20 Apr 24, 2019
Lightweight Concurrent Networking Framework

Dots Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8.0+ / macOS 10.10+ /

Amr Salman 37 Nov 19, 2022
Super lightweight web framework in Swift based on SWSGI

Ambassador Super lightweight web framework in Swift based on SWSGI Features Super lightweight Easy to use, designed for UI automatic testing API mocki

Envoy 170 Nov 15, 2022
Lightweight, flexible HTTP server framework written in Swift

Hummingbird Lightweight, flexible server framework written in Swift. Hummingbird consists of three main components, the core HTTP server, a minimal we

Hummingbird 245 Dec 30, 2022
Lightweight Networking and Parsing framework made for iOS, Mac, WatchOS and tvOS.

NetworkKit A lightweight iOS, Mac and Watch OS framework that makes networking and parsing super simple. Uses the open-sourced JSONHelper with functio

Alex Telek 30 Nov 19, 2022
A tool to build projects on MacOS and a remote linux server with one command

DualBuild DualBuild is a command line tool for building projects on MacOS and a remote Linux server. ##Setup Install the repository git clone https://

Operator Foundation 0 Dec 26, 2021
A phantom type is a custom type that has one or more unused type parameters.

PhantomTypes A phantom type is a custom type that has one or more unused type parameters. Phantom types allow you to enforce type-safety without sacri

null 3 Nov 4, 2022
Open source SDK to quickly integrate subscriptions, stop worring about code maintenance, and getting advanced real-time data. Javascript / iOS glue framework

Open source SDK to quickly integrate subscriptions, stop worring about code maintenance, and getting advanced real-time data. Javascript / iOS glue framework

glassfy 5 Nov 7, 2022
A peer to peer framework for OS X, iOS and watchOS 2 that presents a similar interface to the MultipeerConnectivity framework

This repository is a peer to peer framework for OS X, iOS and watchOS 2 that presents a similar interface to the MultipeerConnectivity framework (which is iOS only) that lets you connect any 2 devices from any platform. This framework works with peer to peer networks like bluetooth and ad hoc wifi networks when available it also falls back onto using a wifi router when necessary. It is built on top of CFNetwork and NSNetService. It uses the newest Swift 2's features like error handling and protocol extensions.

Manav Gabhawala 93 Aug 2, 2022