Man, stumped on this one. Trying to download a file with AFNetworking and the best I can do is capture the progress bytes in the downloadProgressBlock. I\'ve tried many differ
You can simply use this feature that is included on AFNetworking and even save it to disk -
Notice the operation.outputStream
:
NSMutableURLRequest* rq = [api requestWithMethod:@"GET" path:@"YOUR/URL/TO/FILE" parameters:nil];
AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:rq] autorelease];
NSString* path=[@"/PATH/TO/APP" stringByAppendingPathComponent: imageNameToDisk];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"SUCCCESSFULL IMG RETRIEVE to %@!",path)
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// Deal with failure
}];
EDIT : missed
[operation start];
EDIT : ...or if you use an AFHTTPClient * apiClient :
// [apiClient enqueueHTTPRequestOperation:operation];