You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/15 03:53:37 UTC
ios commit: Fix FileTransfer.download failing for file: URLs.
Updated Branches:
refs/heads/master 66945320a -> f4e7a2b0d
Fix FileTransfer.download failing for file: URLs.
https://issues.apache.org/jira/browse/CB-2183
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f4e7a2b0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f4e7a2b0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f4e7a2b0
Branch: refs/heads/master
Commit: f4e7a2b0d4b62c1669c7ca2f8364ead92f655d55
Parents: 6694532
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jan 14 21:53:02 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jan 14 21:53:02 2013 -0500
----------------------------------------------------------------------
CordovaLib/Classes/CDVFileTransfer.m | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f4e7a2b0/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index edda9f7..81d573f 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -492,16 +492,19 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
{
// required for iOS 4.3, for some reason; response is
// a plain NSURLResponse, not the HTTP subclass
- if (![response isKindOfClass:[NSHTTPURLResponse class]]) {
- self.responseCode = 403;
+ if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
+ NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
+
+ self.responseCode = [httpResponse statusCode];
self.bytesExpected = [response expectedContentLength];
- return;
+ } else if ([response.URL isFileURL]) {
+ NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[response.URL path] error:nil];
+ self.responseCode = 200;
+ self.bytesExpected = [attr[NSFileSize] longLongValue];
+ } else {
+ self.responseCode = 200;
+ self.bytesExpected = NSURLResponseUnknownLength;
}
-
- NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
-
- self.responseCode = [httpResponse statusCode];
- self.bytesExpected = [response expectedContentLength];
}
- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error