• Stars
    star
    923
  • Rank 49,181 (Top 1.0 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Concurrent large files downloads for iOS

TCBlobDownload

Build Status Pod version Pod platform Gitter


If you are developing for iOS 7+, please consider using TCBlobDownloadSwift.

However, TCBlobDownload is still maintained and relevant for iOS 5+ projects.


TCBlobDownload uses NSOperations to download large files (typically videos, music... well: BLOBs) using NSURLConnection in background threads.

Tested with files from ~150MB to ~1.2GB, mostly videos.

I've implemented TCBlobDownloader which extends NSOperation and use TCBlobDownloadManager to execute it. You can set a delegate or use blocks for each download to update your views etc…

Requires iOS 5.0 or later and ARC.

Features

  1. Download files in background threads
  2. Blocks or delegate style
  3. Pause and resume a download
  4. Set a maximum number of concurrent downloads
  5. Custom download path
  6. Download speed and remaining time
  7. Download cancellation
  8. Download dependencies

Documentation 📚

Browse the documentation on Cocoadocs or add it directly to Xcode by downloading the docset and placing it into ~/Library/Developer/Shared/Documentation/DocSets/. (or use Dash)

Installation

CocoaPods

Add the following to your Podfile and run $ pod install:

pod 'TCBlobDownload'

If you don't have CocoaPods installed or integrated into your project, you can learn how to do so here.

(Also be sure the $(inherited) flag is set in your Project's Target -> Build Settings -> Other Linker Flags)

Import as a static library

  1. Drag and drop TCBlobDownload.xcodeproj from Finder to your opened project.
  2. Project's Target -> Build Phases -> Target Dependencies -> add TCBlobDownload. Then, click Link binary with libraries and add libTCBlobDownload.a (no worries if it's red).
  3. Go to build settings, switch "always search user paths" to YES and add $(PROJECT_TEMP_DIR)/../UninstalledProducts/include to "User Header Search Paths".
  4. Project's Target -> Build Settings -> Other Linker Flags -> Add -ObjC
  5. Import the lib. (no worries if no autocomplete)
#import <TCBlobDownload/TCBlobDownload.h>

Examples 👓

1. Blocks

To immediately start a download in the default TCBlobDownloadManager directory (tmp/ by default):

TCBlobDownloadManager *sharedManager = [TCBlobDownloadManager sharedInstance];

TCBlobDownloader *downloader = [sharedManager startDownloadWithURL:@"http://give.me/abigfile.avi"
                downloadPath:nil
               firstResponse:^(NSURLResponse *response) {

               }
               progress:^(uint64_t receivedLength, uint64_t totalLength, NSInteger remainingTime, float progress) {
                 // downloader.remainingTime
                 // downloader.speedRate
               }
               error:^(NSError *error) {

               }
               complete:^(BOOL downloadFinished, NSString *pathToFile) {

               }];

If you set a custom path:

NSString *customPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"My/Custom/Path/"];

TCBlobDownloader *downloader = [sharedManager startDownloadWithURL:@"http://give.me/abigfile.avi"
                                                        customPath:customPath // here we set the path
                                                       andDelegate:nil];

This will create the given path if needed and download the file in the Path/ directory. Please note that during the download process you have no control over the file name as explained with reasons why in the documentation. Remember that you should follow the iOS Data Storage Guidelines.

2. Delegate

You can either set a delegate which can implement those optional methods if delegates have your preference over blocks:

- (void)download:(TCBlobDownloader *)download didReceiveFirstResponse:(NSURLResponse *)response
{

}

- (void)download:(TCBlobDownloader *)download didReceiveData:(uint64_t)received onTotal:(uint64_t)total
{
  // download.remainingTime
  // download.speedRate
}

- (void)download:(TCBlobDownloader *)download didStopWithError:(NSError *)error
{

}

- (void)download:(TCBlobDownloader *)download didFinishWithSucces:(BOOL)downloadFinished atPath:(NSString *)pathToFile
{

}

3. Other features

  • If a download has been stopped and the local file has not been deleted, when you will restart the download to the same local path, the download will start where it has stopped using the HTTP Range header (14.35).

  • You can also set dependencies in your downloads using the addDependentDownload: method from TCBlobDownloader.

See documentation for more details.

Roadmap 🚀

If you have any idea or request, please suggest it! 😃

  • Multi segmented downloads
  • Dash XML feed for documentation versioning

More Repositories

1

lua-resty-mlcache

Layered caching library for OpenResty
Perl
370
star
2

lua-resty-jit-uuid

Fast and dependency-free UUID library for LuaJIT/ngx_lua
Perl
201
star
3

TCBlobDownloadSwift

Powerful file downloads in Swift
Swift
152
star
4

lua-cassandra

Pure Lua driver for Apache Cassandra
Lua
99
star
5

lua-resty-socket

Automatic LuaSocket/cosockets compatibility module
Perl
36
star
6

TCCopyableLabel

A copyable UILabel subclass
Objective-C
34
star
7

lua-resty-busted

Test OpenResty scripts with busted
Lua
32
star
8

lua-argon2-ffi

LuaJIT FFI binding for the Argon2 password hashing algorithm
Lua
20
star
9

lua-argon2

Lua C binding for the Argon2 password hashing algorithm
C
20
star
10

Equiprose

A static website and blog generator in Node.js
JavaScript
12
star
11

MonteCarlo

A single and multithread Java implementation of the Monte Carlo algorithm.
Java
10
star
12

TCQueuePlayer

A wrapper class with controls for AVQueuePlayer
Objective-C
9
star
13

DTC3DViewAnimation

A nice iOS animation
Objective-C
7
star
14

lua-resty-multipart

Multipart parsing library for OpenResty
Lua
7
star
15

node-recursive-search

Recursively search a file in given directory
CoffeeScript
5
star
16

setup-openresty

JavaScript
3
star
17

TCProgressView

A customizable progress view for iOS
Objective-C
3
star
18

Counter

Simple Node.js and Socket.IO example.
JavaScript
2
star
19

kong-tests-compose

Docker compose for Kong's integration test suite
Shell
2
star
20

ECE_hadoop_mahout

Classification of tweets using Mahout
Java
1
star
21

Miranda

The original Equiprose
JavaScript
1
star
22

chasum.net

Personal website
HTML
1
star
23

lapis-syntax

A profound, purple based, dark colored theme for Atom.
CSS
1
star
24

macos-unused-files

Bash script to find unused files in a given period of time
Shell
1
star
25

homebrew-kong

Homebrew tap for Kong
Ruby
1
star
26

TweetStats

Assignment for the Software Quality course at ECE Paris 2013
Java
1
star