alpha0010 / react-native-file-access

Filesystem access for React Native
MIT License
298 stars 18 forks source link

fix writeFile base64string failed #60

Closed jamninetyfive closed 1 year ago

jamninetyfive commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch react-native-file-access@2.5.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-file-access/ios/FileAccess.swift b/node_modules/react-native-file-access/ios/FileAccess.swift
index 894a8fe..623da20 100644
--- a/node_modules/react-native-file-access/ios/FileAccess.swift
+++ b/node_modules/react-native-file-access/ios/FileAccess.swift
@@ -329,7 +329,7 @@ class FileAccess: RCTEventEmitter {
             do {
                 if encoding == "base64" {
                     let pathUrl = URL(fileURLWithPath: path.path())
-                    guard let decoded = Data(base64Encoded: data) else {
+                    guard let decoded = Data(base64Encoded: data, options: .ignoreUnknownCharacters) else {
                         reject("ERR", "Failed to write to '\(path)', invalid base64.", nil)
                         return
                     }

This issue body was partially generated by patch-package.