|
@@ -737,17 +737,21 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
|
|
__block NSURLSessionUploadTask *uploadTask = nil;
|
|
|
url_session_manager_create_task_safely(^{
|
|
|
uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
|
|
|
- });
|
|
|
-
|
|
|
- // uploadTask may be nil on iOS7 because uploadTaskWithRequest:fromFile: may return nil despite being documented as nonnull (https://devforums.apple.com/message/926113#926113)
|
|
|
- if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) {
|
|
|
- for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) {
|
|
|
- uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
|
|
|
+
|
|
|
+ // uploadTask may be nil on iOS7 because uploadTaskWithRequest:fromFile: may return nil despite being documented as nonnull (https://devforums.apple.com/message/926113#926113)
|
|
|
+ if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) {
|
|
|
+ for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) {
|
|
|
+ uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL];
|
|
|
+ }
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ if (uploadTask) {
|
|
|
+ [self addDelegateForUploadTask:uploadTask
|
|
|
+ progress:uploadProgressBlock
|
|
|
+ completionHandler:completionHandler];
|
|
|
}
|
|
|
|
|
|
- [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler];
|
|
|
-
|
|
|
return uploadTask;
|
|
|
}
|
|
|
|