Pause,Resume,Cancel Upload Task Using NSURLSession UploadTask

Tabish Sohail picture Tabish Sohail · Jan 7, 2015 · Viewed 8.1k times · Source

I am developing an app to upload multiple files using NSURLSession, right now my files are successfully uploaded. But now what i want to achieve is to pause,resume and cancel the uploads just like we do in download tasks. Is it possible.? Any help would be appreciated. Thnx

Answer

Tabish Sohail picture Tabish Sohail · Jan 27, 2015

I have studied alot but could find nothing .After i tried this on my code assuming this as a download task ,I came to know that we can "pause , resume" upload tasks as well using NSURLSession just we do in downloading tasks.

To pause a task simply call [yourUploadTask suspend]; to resume [yourUploadTask resume]; To cancel [yourUploadTask cancel];

It might help someone working on uploadTask using NSURLSession.