Browse Source

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

JoshB 7 years ago
parent
commit
712c8a3a07
1 changed files with 5 additions and 5 deletions
  1. 5
    5
      ios/RNFetchBlobFS.m

+ 5
- 5
ios/RNFetchBlobFS.m View File

@@ -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