From 141f9960523504ecb32d042b34184904ff9df7d2 Mon Sep 17 00:00:00 2001 From: Denis Babineau Date: Wed, 26 Aug 2015 23:58:50 -0300 Subject: [PATCH] fix downloadFile method on ios; invalid native path and not using proper instance of CDVFile --- src/ios/CordovaHttpPlugin.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index d938047..5630d2b 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -177,6 +177,10 @@ [self setRequestHeaders: headers]; + if ([filePath hasPrefix:@"file://"]) { + filePath = [filePath substringFromIndex:7]; + } + CordovaHttpPlugin* __weak weakSelf = self; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; [manager GET:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { @@ -229,10 +233,10 @@ return; } - CDVFile *file = [[CDVFile alloc] init]; + id filePlugin = [self.commandDelegate getCommandInstance:@"File"]; NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; [dictionary setObject:[NSNumber numberWithInt:operation.response.statusCode] forKey:@"status"]; - [dictionary setObject:[file getDirectoryEntry:filePath isDirectory:NO] forKey:@"file"]; + [dictionary setObject:[filePlugin getDirectoryEntry:filePath isDirectory:NO] forKey:@"file"]; CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary]; [weakSelf.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) {