Skip to content

Commit 17732a0

Browse files
committed
fix(filesystem): unexpected error when saving file lead to crashing the app
1 parent f45a9ee commit 17732a0

File tree

1 file changed

+6
-1
lines changed
  • filesystem/android/src/main/java/com/capacitorjs/plugins/filesystem

1 file changed

+6
-1
lines changed

filesystem/android/src/main/java/com/capacitorjs/plugins/filesystem/Filesystem.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ public void saveFile(File file, String data, Charset charset, Boolean append) th
6161
} else {
6262
//remove header from dataURL
6363
if (data.contains(",")) {
64-
data = data.split(",")[1];
64+
String[] tmp = data.split(",");
65+
if (tmp.length > 1) {
66+
data = tmp[1];
67+
} else {
68+
throw new IllegalArgumentException("The supplied data is not valid base64 content.");
69+
}
6570
}
6671
FileOutputStream fos = new FileOutputStream(file, append);
6772
fos.write(Base64.decode(data, Base64.NO_WRAP));

0 commit comments

Comments
 (0)