Giter VIP home page Giter VIP logo

digger's Introduction

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.

digger's People

Contributors

cornerant avatar moshiwu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.