fix downloadFile method on ios; invalid native path and not using proper instance of CDVFile

This commit is contained in:
Denis Babineau
2015-08-26 23:58:50 -03:00
parent cabb0db9de
commit 141f996052
+6 -2
View File
@@ -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) {