System:
OS: macOS Mojave 10.14.4
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 24.99 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28, 29
Build Tools: 27.0.3, 28.0.3
System Images: android-19 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
rn-fetch-blob": "0.12.0",
Description and solution for the issue:
I have a particular pdf file that cannot be converted from base64 to file just in ios. When the base64 content will be parsed to a pdf file (application/pdf) the base64 decode cannot be done because there is some characters that aren't known. This conversion exception results in a file stored in cache folder with 0 bytes. In Android it's run perfectly.
I could fix the problem editing the file RNFetchBlobFS.m and changed the line 379 as follow:
from : content = [[NSData alloc] initWithBase64EncodedString:data options:0];
to: content = [[NSData alloc] initWithBase64EncodedString:data options:NSDataBase64DecodingIgnoreUnknownCharacters];
Basically I passed the enum NSDataBase64DecodingIgnoreUnknownCharacters to ignore the unknown characters instead of enum 0.
System: OS: macOS Mojave 10.14.4 CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz Memory: 24.99 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.12.0 - /usr/local/bin/node Yarn: 1.19.1 - /usr/local/bin/yarn npm: 6.11.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0 Android SDK: API Levels: 23, 24, 25, 26, 27, 28, 29 Build Tools: 27.0.3, 28.0.3 System Images: android-19 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 11.1/11A1027 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.2 => 0.61.2 rn-fetch-blob": "0.12.0",
I could fix the problem editing the file RNFetchBlobFS.m and changed the line 379 as follow:
from : content = [[NSData alloc] initWithBase64EncodedString:data options:0]; to: content = [[NSData alloc] initWithBase64EncodedString:data options:NSDataBase64DecodingIgnoreUnknownCharacters];
Basically I passed the enum NSDataBase64DecodingIgnoreUnknownCharacters to ignore the unknown characters instead of enum 0.
changing this method:
May this little change can be done in next version of rn-fetch-blob.
Best Regards, Cassio Seffrin