Skip to content

Commit 3fcfd54

Browse files
authored
Change Android Base64 mode to omit line breaks
This is mostly a suggestion: the DEFAULT options of Base64.encodeString() adds line breaks to wrap the output to 80 (or something like that) characters. The iOS base64 encoder does *not* do this, making the Android and iOS output of readFile(..., 'base64') different. I believe this change would make them the same. (Additionally, a lot of base64 decoders, reasonably or not, do not seem to correctly handle the line breaks. I had to strip them out manually to use as input for pdf-lib, e.g..
1 parent 576ed9e commit 3fcfd54

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

android/src/main/java/com/alpha0010/fs/FileAccessModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class FileAccessModule(reactContext: ReactApplicationContext) :
301301
try {
302302
val data = openForReading(path).use { it.readBytes() }
303303
if (encoding == "base64") {
304-
promise.resolve(Base64.encodeToString(data, Base64.DEFAULT))
304+
promise.resolve(Base64.encodeToString(data, Base64.NO_WRAP))
305305
} else {
306306
promise.resolve(data.decodeToString())
307307
}

0 commit comments

Comments
 (0)