I am using AFNetworking Library, How to download the large amount of data using AFNetworking Library to show the better performance?
I have followed the following steps:
".zip" files downloading the content from server.
I have added one url , like this i have so many url's to download the content from the server. It takes too much time. How to perform the fast downloading from server.
My Query is: If the url was not found on server, then it executes failure state. but the ".zip" is storing in documents folder with empty content like zerobytes.
while am trying to extract the .zip it shows .cpgz format. Let us know how to resolve this?
-(void)downloadSingFile:(NSUInteger )activityAtIndex totalCount:(NSUInteger )lessonTotalCount{
// http://118.102.131.158/IYG_wrapper/IYG_updated/IYG_G7_L03/IYG_UN_Mall.zip
NSString *activityUrl = [filterObjects objectAtIndex:activityAtIndex];
NSURL *zipFileAtUrl = [NSURL URLWithString:[activityUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
BOOL success = [libraryObj createFolderWithName:rootName];
if (success) {
activityPath = [[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:rootName] stringByAppendingPathComponent:[zipFileAtUrl lastPathComponent]];
}
NSURLRequest *request = [NSURLRequest requestWithURL:zipFileAtUrl];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:activityPath append:NO];
[operation setCompletionBlock:^{
sleep(1);
NSLog(@"sucessfully downloaded file %d",activityIndx);
[self extractSingleActivityAtindex:activityIndx];
}];
[operation start];
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float percentDone = ((float)(totalBytesRead) / (float)(totalBytesExpectedToRead));
self.tableView.alpha = 0.7;
progressView.hidden = NO;
progressAlert.hidden = NO;
progressAlert.labelText = @"Downloading..";
[self updateProgress:percentDone];
NSLog(@"progress float value is: %.2f",percentDone);
}];
}
1.Please let us know, now i dont want to download the which is exist in documents folder path and also let us know whether the the file has been downloaded sucessfully or not.