incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: Fixed CB-543 - FileTransfer.upload WebKit discarded an uncaught exception
Date Fri, 20 Apr 2012 22:14:16 GMT
Updated Branches:
  refs/heads/master 159cdfe4d -> 3794f4db6


Fixed CB-543 - FileTransfer.upload WebKit discarded an uncaught exception


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/3794f4db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/3794f4db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/3794f4db

Branch: refs/heads/master
Commit: 3794f4db6ffe6c21727b48c216c3481ffa8dd563
Parents: 159cdfe
Author: Shazron Abdullah <shazron@apache.org>
Authored: Fri Apr 20 15:14:10 2012 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Fri Apr 20 15:14:10 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVFileTransfer.m               |   12 ++++----
 CordovaLib/Classes/NSMutableArray+QueueAdditions.h |    7 +++++
 CordovaLib/Classes/NSMutableArray+QueueAdditions.m |   22 ++++++++++++++-
 3 files changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/3794f4db/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index f1a7ccb..68d7b7b 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -17,9 +17,7 @@
  under the License.
  */
 
-#import "CDVFileTransfer.h"
-#import "CDVFile.h"
-#import "CDVDebug.h"
+#import "CDV.h"
 
 @implementation CDVFileTransfer
 
@@ -33,8 +31,8 @@
     NSString* filePath = (NSString*)[arguments objectAtIndex:1];
     NSString* server = (NSString*)[arguments objectAtIndex:2];
     NSString* fileKey = (NSString*)[arguments objectAtIndex:3];
-    NSString* fileName = (NSString*)[arguments objectAtIndex:4];
-    NSString* mimeType = (NSString*)[arguments objectAtIndex:5];
+    NSString* fileName = [arguments objectAtIndex:4 withDefault:@"no-filename"];
+    NSString* mimeType = [arguments objectAtIndex:5 withDefault:nil];
 //  NSString* trustAllHosts = (NSString*)[arguments objectAtIndex:6]; // allow self-signed
certs
 //  NSString* chunkedMode = (NSString*)[arguments objectAtIndex:7]; // currently unused
     
@@ -138,7 +136,9 @@
     
 	[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
 	[postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\";
filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
-    [postBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]];
+    if (mimeType != nil) {
+        [postBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType]
dataUsingEncoding:NSUTF8StringEncoding]];
+    }
     [postBody appendData:[[NSString stringWithFormat:@"Content-Length: %d\r\n\r\n", [fileData
length]] dataUsingEncoding:NSUTF8StringEncoding]];
 
     DLog(@"fileData length: %d", [fileData length]);

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/3794f4db/CordovaLib/Classes/NSMutableArray+QueueAdditions.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/NSMutableArray+QueueAdditions.h b/CordovaLib/Classes/NSMutableArray+QueueAdditions.h
index e86632e..dd8ba1b 100755
--- a/CordovaLib/Classes/NSMutableArray+QueueAdditions.h
+++ b/CordovaLib/Classes/NSMutableArray+QueueAdditions.h
@@ -28,3 +28,10 @@
 - (void) enqueue:(id)obj;
 
 @end
+
+
+@interface NSMutableArray (Comparisons)
+
+- (id) objectAtIndex:(NSUInteger)index withDefault:(id)aDefault;
+
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/3794f4db/CordovaLib/Classes/NSMutableArray+QueueAdditions.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/NSMutableArray+QueueAdditions.m b/CordovaLib/Classes/NSMutableArray+QueueAdditions.m
index c2736f0..4267947 100755
--- a/CordovaLib/Classes/NSMutableArray+QueueAdditions.m
+++ b/CordovaLib/Classes/NSMutableArray+QueueAdditions.m
@@ -55,4 +55,24 @@
     [self addObject:object];
 }
 
-@end
\ No newline at end of file
+@end
+
+@implementation NSMutableArray (Comparisons)
+
+- (id) objectAtIndex:(NSUInteger)index withDefault:(id)aDefault
+{
+    id obj = nil;
+    @try {
+        obj = [self objectAtIndex:index];
+        if (obj == [NSNull null] || obj == nil) {
+            return aDefault;
+        }
+    }
+    @catch (NSException* exception) {
+        NSLog(@"Exception - Name: %@ Reason: %@", [exception name], [exception reason]);
+    }
+    
+    return obj;
+}
+
+@end


Mime
View raw message