Repository: cordova-plugin-file-transfer Updated Branches: refs/heads/master a762f3fe5 -> 866349eb8
CB-9840 Fallback file-transfer upload/download response encoding to latin1 in case not encoded with UTF-8 on iOS Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/e14b7e53 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/e14b7e53 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/e14b7e53 Branch: refs/heads/master Commit: e14b7e539119010ade7aa4ab9f9af9ec2da0a1c8 Parents: a762f3f Author: FF Xu <[email protected]> Authored: Mon Mar 23 02:16:56 2015 +0800 Committer: daserge <[email protected]> Committed: Fri Dec 4 13:26:33 2015 +0300 ---------------------------------------------------------------------- src/ios/CDVFileTransfer.m | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/e14b7e53/src/ios/CDVFileTransfer.m ---------------------------------------------------------------------- diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m index aa60c52..45e83eb 100644 --- a/src/ios/CDVFileTransfer.m +++ b/src/ios/CDVFileTransfer.m @@ -569,6 +569,9 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) if (self.direction == CDV_TRANSFER_UPLOAD) { uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding]; + if (uploadResponse == nil) { + uploadResponse = [[NSString alloc] initWithData: self.responseData encoding:NSISOLatin1StringEncoding]; + } if ((self.responseCode >= 200) && (self.responseCode < 300)) { // create dictionary to return FileUploadResult object @@ -593,6 +596,10 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self.filePlugin makeEntryForURL:self.targetURL]]; } else { downloadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding]; + if (downloadResponse == nil) { + downloadResponse = [[NSString alloc] initWithData: self.responseData encoding:NSISOLatin1StringEncoding]; + } + CDVFileTransferError errorCode = self.responseCode == 404 ? FILE_NOT_FOUND_ERR : (self.responseCode == 304 ? NOT_MODIFIED : CONNECTION_ERR); result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:errorCode AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:downloadResponse]]; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
