I am using AFNetworking to download large file into my iPad app.
An instance of AFHTTPRequestOperation is used to download this file. Below is the code for referenc
After spending sometime I figured out how to pause and resume the download.
AFNetworking has extensions one of them is AFDownloadRequestOperation which is essentially used to handle the pause and resume of large files. So instead of using AFHTTPRequestOperation here AFDownloadRequestOperation is to be used. Below is sample code
//request is the NSRequest object for the file getting downloaded and targetPath is the final location of file once its downloaded. Don't forget to set shouldResume to YES AFDownloadRequestOperation *operation = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:targetPath shouldResume:YES]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { //handel completion }failure:^(AFHTTPRequestOperation *operation, NSError *error) { //handel failure }]; [operation setProgressiveDownloadProgressBlock:^(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile) { //handel progress }]; //since this class is subclass of AFHTTPClient so the operation is added to request queue [self enqueueHTTPRequestOperation:operation]; //used to pause the download -(void)pauseDownload{ [operation pause]; } //used to resume download -(void)resumeDownload{ [operation resume]; }