diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m index dca440a..ee32b92 100644 --- a/src/ios/CDVFileTransfer.m +++ b/src/ios/CDVFileTransfer.m @@ -305,13 +305,14 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) fs = [[self.commandDelegate getCommandInstance:@"File"] filesystemForURL:sourceURL]; } if (fs) { + __weak CDVFileTransfer* weakSelf = self; [fs readFileAtURL:sourceURL start:0 end:-1 callback:^(NSData *fileData, NSString *mimeType, CDVFileError err) { if (err) { // We couldn't find the asset. Send the appropriate error. - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:NOT_FOUND_ERR AndSource:source AndTarget:server]]; - [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[weakSelf createFileTransferError:NOT_FOUND_ERR AndSource:source AndTarget:server]]; + [weakSelf.commandDelegate sendPluginResult:result callbackId:command.callbackId]; } else { - [self uploadData:fileData command:command]; + [weakSelf uploadData:fileData command:command]; } }]; return;