diff --git a/src/ios/CDVFileTransfer.h b/src/ios/CDVFileTransfer.h index 07feb85..ab95221 100644 --- a/src/ios/CDVFileTransfer.h +++ b/src/ios/CDVFileTransfer.h @@ -52,6 +52,7 @@ extern NSString* const kOptionsKeyCookie; AndTarget:(NSString*)target AndHttpStatus:(int)httpStatus AndBody:(NSString*)body; +@property (nonatomic, strong) NSOperationQueue* queue; @property (readonly) NSMutableDictionary* activeTransfers; @end diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m index 9125e2f..27e1204 100644 --- a/src/ios/CDVFileTransfer.m +++ b/src/ios/CDVFileTransfer.m @@ -412,13 +412,19 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) [delegate cancelTransfer:delegate.connection]; }]; - delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate]; + delegate.connection = [[NSURLConnection alloc] initWithRequest:req delegate:delegate startImmediately:NO]; + + if (self.queue == nil) { + self.queue = [[NSOperationQueue alloc] init]; + } + [delegate.connection setDelegateQueue:self.queue]; if (activeTransfers == nil) { activeTransfers = [[NSMutableDictionary alloc] init]; } - [activeTransfers setObject:delegate forKey:delegate.objectId]; + + [delegate.connection start]; } - (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target