Shawon
Shawon

Reputation: 31

Batch Downloading files using NSURLSession with file integrity on iOS

We have an application that downloads user contents. Our files could be big ones and usually our users download as batch. Our users having different troubles on download that described below. We want to refactor whole download process and possible use a library for that. We would like your opinion on problems and solutions.

Current Process:

We have list of items, which users can download, each item consists of a single file or multiple files (users don’t aware of that). User can initiate download of an item by pressing the “download button” on the list, and we support concurrent download of items. Remember each item can have multiple files or single file. We also need to show progress of download for items individually. We are using NSURLConnection to download files it was developed since iOS 4.

Problems:

What we need:

In which solution we can make sure each of our needs covered? How can we achieve this?

Upvotes: 3

Views: 1280

Answers (1)

Karaban
Karaban

Reputation: 151

Ok it can be simply achieved by using NSUrlSession (NSURLSessionDataTask, NSURLSessionDownloadTask) - it will solve all your downloading problems(multiple threads to fast download(concurrent downloading ),resume, pause, cancel and etc.) including background downloads . Also it supports completion block which can be helpful for file integrity check.
To check for Internet connection in order to pause or resume downloads you can use Reachability library.
If you wish to use third-party library I stronglly recommend you to use AFNetWorking (everything from your requirements can be done by this library)-->https://github.com/AFNetworking/AFNetworking

Also, this tutorial can be helpfull for your needs - http://www.appcoda.com/background-transfer-service-ios7/

Upvotes: 1

Related Questions