ソースを参照

[iOS] Fix for RNFetchBlob.writeChunk failing to write base64 encoded strings (#433)

JoshB 7 年 前
コミット
712c8a3a07
共有1 個のファイルを変更した5 個の追加5 個の削除を含む
  1. 5
    5
      ios/RNFetchBlobFS.m

+ 5
- 5
ios/RNFetchBlobFS.m ファイルの表示

@@ -568,11 +568,11 @@ NSMutableDictionary *fileStreams = nil;
568 568
 
569 569
 // Write file chunk into an opened stream
570 570
 - (void)writeEncodeChunk:(NSString *) chunk {
571
-    NSMutableData * decodedData = [NSData alloc];
571
+    NSData * decodedData = nil;
572 572
     if([[self.encoding lowercaseString] isEqualToString:@"base64"]) {
573
-        decodedData = [[NSData alloc] initWithBase64EncodedData:chunk options:0];
574
-    }
575
-    if([[self.encoding lowercaseString] isEqualToString:@"utf8"]) {
573
+        decodedData = [[NSData alloc] initWithBase64EncodedString:chunk options: NSDataBase64DecodingIgnoreUnknownCharacters];
574
+    } 
575
+    else if([[self.encoding lowercaseString] isEqualToString:@"utf8"]) {
576 576
         decodedData = [chunk dataUsingEncoding:NSUTF8StringEncoding];
577 577
     }
578 578
     else if([[self.encoding lowercaseString] isEqualToString:@"ascii"]) {
@@ -793,4 +793,4 @@ NSMutableDictionary *fileStreams = nil;
793 793
     return;
794 794
 }
795 795
 
796
-@end
796
+@end