Skip to content

Commit 7552db7

Browse files
committed
Fix "failed to stat path null" on Android
1 parent d0d1e34 commit 7552db7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

FileReader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@
344344
// https://github.com/RonRadtke/react-native-blob-util/issues/117
345345
path = decodeURIComponent(path);
346346

347+
// Android need this otherwise startsWith "content://com.android.externalstorage.documents/document/primary:..." will
348+
// `failed to stat path "null"
349+
// because it does not exist or it is not a folder` as err.message
350+
path = path.replace(/^content:\/\/com.android.externalstorage.documents\/document\/primary:/, '/sdcard/');
351+
347352
fs.stat(path).then(function(stat) {
348353
file.lastModified = stat.lastModified;
349354
file.lastModifiedDate = new Date(stat.lastModified);

0 commit comments

Comments
 (0)