joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.84k stars 784 forks source link

Android 8,9,10 - issue on emulator - NumberFormatException - getRealPathFromURI #498

Open Yurrili opened 4 years ago

Yurrili commented 4 years ago

Hi, I have issue with get image from downloads file on emulator. My path: content://com.android.providers.downloads.documents/document/msf%3A253

And I've got this error: java.lang.NumberFormatException: For input string: "msf:253" at java.lang.Long.parseLong(Long.java:594) at java.lang.Long.valueOf(Long.java:808) at com.RNFetchBlob.Utils.PathResolver.getRealPathFromURI(PathResolver.java:47)

Is it connected to testing on emulator?

I am using:

Android: buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "28.0.0" RN: "react": "16.9.0", "react-native": "0.61.4",

ThadeusAjayi commented 4 years ago

Am having this same issue, I use a real device: Google Pixel 2xl running android 10

aprilmintacpineda commented 3 years ago

I'm having the same trouble with this path, android seems to sometimes return a path like: content://com.android.providers.downloads.documents/document/893 or like content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fapplication_form.pdf, notice the difference is with the file path. When I do:

fs.stat('content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fapplication_form.pdf');

it succeeds but when I do:

fs.stat('content://com.android.providers.downloads.documents/document/893');

even though both of which was returned by expo-document-picker

Solution: use https://github.com/flyerhq/react-native-android-uri-path