AFNetworking nie może pobrać dużych plików
Obecnie próbuję pobrać niektóre pliki za pomocą AFNetworking, dla względnie małych plików wydaje się to działać, ale próbuję mniejszego większego pliku (17 MB) i wydaje się, że po prostu ulega awarii bez żadnego błędu.
Adres URL łączy się z plikiem lokalnym:http: //test.local/wp-content/uploads/2012/07/test.pdf (Używam go w symulatorze, więc jest dostępny)
Jedyne wyjście, które otrzymuję, jest w bloku postępu
postęp: 0,009022
Kiedy sprawdzam system plików, wygląda na to, że plik istnieje, ale tylko kilka KB.
Czy jest to znany błąd w AFNetworking, a może po prostu robię coś złego.
- (void)downloadIssue:(Issue *)issue
{
NSString *fileName = [issue.pdf lastPathComponent];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName];
NSURL *url = [NSURL URLWithString:issue.pdf];
AFHTTPClient *httpClient = [[[AFHTTPClient alloc] initWithBaseURL:url] autorelease];
NSURLRequest *request = [httpClient requestWithMethod:@"GET" path:issue.pdf parameters:nil];
AFURLConnectionOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"PDF DOWNLOAD COMPLETE");
issue.pdf_location = filePath;
// send out a notification with the issue
[[NSNotificationCenter defaultCenter] postNotificationName:@"PDF_DOWNLOAD_COMPLETE" object:nil userInfo:[NSDictionary dictionaryWithObject:issue forKey:@"issue"]];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"PDF DOWNLOAD FAILED");
// send out a notification with the issue
[[NSNotificationCenter defaultCenter] postNotificationName:@"PDF_DOWNLOAD_FAILED" object:nil userInfo:[NSDictionary dictionaryWithObject:issue forKey:@"issue"]];
}];
[operation setDownloadProgressBlock:^(NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
float progress = (float)totalBytesRead / totalBytesExpectedToRead;
NSLog(@"progress: %f", progress);
[[NSNotificationCenter defaultCenter] postNotificationName:@"PDF_DOWNLOAD_PROGRESS" object:nil userInfo:[NSDictionary dictionaryWithObjectsAndKeys: issue, @"issue", progress, @"progress", nil]];
}];
[_queue addOperation:operation];
}