nicht funktioniert IchAFNetworking 3.0 Hintergrund hochladen
-(void)uploadMultipleImagesUsingAFNetworkingMultipartFormat:(id)sender {
NSArray * directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[[FileUtility basePath] stringByAppendingPathComponent:[self getPathOfRootImageFolderDocumentId:@"1"]] error:nil];
NSString *path = [directoryContents objectAtIndex:0];
NSString* filePath=[[[FileUtility basePath] stringByAppendingPathComponent:[self getPathOfRootImageFolderDocumentId:@"1"]] stringByAppendingPathComponent:path];
NSURLSessionConfiguration *config = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"com.uploadDocument.Background"];
MBProgressHUD *progres = [MBProgressHUD showHUDAddedTo:[[AppDelegate sharedInstance] window] animated:YES];
progres.mode = MBProgressHUDModeDeterminateHorizontalBar;
progres.progress = 0.0;
if (!self.sessionManager) {
_sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:config];
}
NSError *error;
NSMutableURLRequest *requet= [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"URLTO UPLOAD" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
NSError *error1;
[formData appendPartWithFileURL:[NSURL fileURLWithPath:filePath] name:@"fileUpload" fileName:path mimeType:@"image/jpeg" error:&error1];
NSLog(@"%@",error1);
} error:&error];
NSURLSessionUploadTask *uploadTask = [self.sessionManager uploadTaskWithRequest:requet fromFile:[NSURL fileURLWithPath:filePath] progress:^(NSProgress * _Nonnull uploadProgress) {
dispatch_async(dispatch_get_main_queue(), ^{
[progres setProgress:uploadProgress.fractionCompleted];
});
NSLog(@" Progress %f",uploadProgress.fractionCompleted);
} completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:[AppDelegate sharedInstance].window animated:YES];
});
}];
[uploadTask resume];
}
umgesetzt haben, aber wenn ich es im Hintergrund setzen, und nach einiger Zeit aktiv gesetzt. Ich beobachte diesen Prozess von wo aus pausiert wird.
Wie wird die Aufgabe auch im Hintergrund fortgesetzt?
Verweisen Sie auf diesen Beitrag http://stackoverflow.com/questions/7800614/does-afnetworking-have-backgrounding-support/7881866#7881866 – kb920
Ist Ihr Problem gelöst? –
nein, keine Lösung finden @EktaMakadiya –