Code Monkey home page Code Monkey logo

tcblobdownloadswift's Introduction

TCBlobDownloadSwift

Powerful file downloads for iOS 7+ with NSURLSession in Swift.

TCBlobDownloadSwift makes it easy to quickly download one or several large file(s) from your backend or the Internet right into your app. Give it an URL, a directory (or not, it can also download into the user's tmp folder), a name (or not, it can also give your file a default name), and it will take care of everything.

See the Usage section for examples.

Features

  • File downloads with NSURLSession (including background downloads/pause/resume)
  • File management (download directory + customizable filename)
  • Download tasks configuration (cookies, timeout, number of concurrent connections...)
  • Progression/Completion Protocol (delegate style)
  • Progression/Completion Closures
  • Complete example project with concurrent file downloading

Requirements

  • iOS 7.0+ / Mac OS X 10.9+

Installation

CocoaPods

Add the following to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'TCBlobDownloadSwift', '~> 0.1.0'

And run:

$ pod install

Here is a helpful article about setting up your project to use CocoaPods with Swift.

Import as an embedded framework
  • Drag and drop TCBlobDownloadSwift.xcodeproj from the Finder to your opened project's file navigator.
  • Project's Target -> Build Phases -> Target Dependencies -> add TCBlobDownloadSwift.framework.
  • Click on the + button at the top left of the panel and select "New Copy Files Phase". Set the "Destination" to "Frameworks", and add TCBlobDownloadSwift.framework.
Import source files

For iOS 7 and other targets which do not support embedded frameworks, copy the source files (Source/*.swift}) into your project.

Usage

Before checking the iOS example project, here is how TCBlobDownloadSwift works in a few lines of code:

Closures

Coming!

Delegate
import TCBlobDownloadSwift

// Here is a simple delegate implementing TCBlobDownloadDelegate.
class DownloadHandler: NSObject, TCBlobDownloadDelegate {
  init() {}

  func download(download: TCBlobDownload, didProgress progress: Float, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
    println("\(progress*100)% downloaded")
  }

  func download(download: TCBlobDownload, didFinishWithError error: NSError?, atLocation location: NSURL?) {
    println("file downloaded at \(location)")
  }
}

let fileURL = NSURL(string: "http://some.huge/file.mp4")
let download = TCBlobDownloadManager.sharedInstance
                                    .downloadFileAtURL(fileURL!, toDirectory: nil, withName: nil, andDelegate: DownloadHandler())

Roadmap

  • Documentation set
  • Full background download example
  • File upload

tcblobdownloadswift's People

Contributors

alexquinlivan avatar bonebox avatar readmecritic avatar thibaultcha 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.