
content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FBittrexv1.csvOnePlus 5T/Downloads then I get this uri:content://com.android.externalstorage.documents/document/primary%3ADownload%2FBittrexv1.csvThe first uri crashes the app, I am not able to read from the first uri. The second uri works fine. Can you let me know if I am doing something wrong or know of any fix for this. Thanks
I am selecting the document using this:
DocumentPicker.show(
{
filetype: [DocumentPickerUtil.allFiles()]
},
(error, res) => {
console.log(res.uri)
this.fileuri = res.uri;
}
);
same error...
Did you figure it out, it's an interesting edge case
same error faced
Can you retry with latest?
Hi, @Elyx0 thanks for looking into it. Currently, I am not working on that project so might be difficult for me to test. If anyone can retry and close this issue. Thanks for the contribution 👍
@Elyx0 Hi, tested with the latest version and still the same result, for me I get :
Error:Error: failed to stat path "null" because it does not exist or it is not a folder
when I try to check the file exist with RNFetchBlob.fs.stat(decodeURIComponent(res.uri)).then(...blah blah)
res.uri is not a file path, FS exists functions are not going to work.
@dantman So how can I check if the file exists or not? or in a better way of asking, is it safe to directly upload the file to the server with res.uri without checking the existence of it?
@Arrow891 If the user was able to pick a file, then it doesn't not exist. If the user can't pick a file then they'll cancel the picker, which will throw a cancelation error you can detect.
i'm having same issue if i pick the doc directly from Download folder the path does not exist so i for that reason i cannot upload file to firebase.
but if i go to my internal storage and i pick the download folder and pick the same folder the uri returned let me upload the file to firebase
this sure only happend in Android, IOS works fine
Do you have any updates? How can I fix it?
Same error, if someone knows how to fix it? we can create a fork with this fix!
It's a critical issue!
Same error here,this is a big problem!
Please be resolved!!! :weary: :weary: :weary:
@Elyx0 solve the problem pleaseee
please someone help ☕
Also interested. We are using RNFetchBlob.fs.stat(res.uri) to check if the file can be accessed, as want to screen out files picked from google drive (as the user may be offline). However calling this with the uri returned for the downloads folder results in failed to stat path "null" ... so we can't use this approach, and I'm not sure how else to do the check.
Also interested. We are using
RNFetchBlob.fs.stat(res.uri)to check if the file can be accessed, as want to screen out files picked from google drive (as the user may be offline). However calling this with the uri returned for the downloads folder results infailed to stat path "null" ...so we can't use this approach, and I'm not sure how else to do the check.
I think it's related to this line
PathResolver.java#L56
please someone help ☕
I fixed it by upgraded rn-fetch-blob package version to 0.12.0 in package.json
"rn-fetch-blob": "0.12.0"
Hope it help
Try out this. It worked for me !
if (res.uri.startsWith('content://')) {
const uriComponents = res.uri.split('/')
const fileNameAndExtension = uriComponents[uriComponents.length - 1]
const destPath = `${RNFS.TemporaryDirectoryPath}/${fileNameAndExtension}`
await RNFS.copyFile(res.uri, destPath)
}
The only issue is that you need memory on device to store the cached file. We would be grateful if somebody brings out a better solution !
@meliodev work like a charm!
@shubhnik
Try to decode the uri before using it
if (Platform.OS === 'ios' || (Platform.OS === 'android' && parsedUri.includes('com.android.providers'))) {
parsedUri = decodeURIComponent(parsedUri);
}
Most helpful comment
i'm having same issue if i pick the doc directly from Download folder the path does not exist so i for that reason i cannot upload file to firebase.
but if i go to my internal storage and i pick the download folder and pick the same folder the uri returned let me upload the file to firebase
this sure only happend in Android, IOS works fine