question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permission Denial Error when trying to upload file picked from ExternalStorageDirectoryPath to fireStore storage

See original GitHub issue

I’m trying to upload a .xlsx file to firestore storage ,I’m using react-native-document-picker to pick the file from ExternalStorageDirectoryPath so when just log the files uri I don’t get the error but as soon as try to upload the file it throws the error .
relevant code :

 const uploadFile=async ()=>{
        try {
          
            const res = await DocumentPicker.pick({
                type: [DocumentPicker.types.allFiles],
            });
            console.log(res.uri) //<-----works fine

            //this is what iscausing the error apparently 
            const task =  Storage().ref('catalogue/'+ res.name).putFile(res.uri);
            task.on('state_changed', 
                sn =>{},
                err=>console.log(err),
                () => {
                   console.log('excel uploaded!'+res.name)
                   Storage()
                   .ref("catalogue").child(res.name).getDownloadURL()
                   .then(url => {
                     console.log('uploaded excel url', url);
                   }).catch(err=>console.log(err))
               }
            )
            await task 
             
           
          } catch (err) {
            if (DocumentPicker.isCancel(err)) {
              // User cancelled the picker, exit any dialogs or menus and move on
            } else {
              throw err;
            }
        }
    }

` I already included the required permissions in my AndroidManifest.xml file and rebuilt the project , although From what I’ve read, MANAGE_DOCUMENTS is a “signature” permission and cannot be added to the manifest.xml or granted by the react native android permission API. <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/> the Error I’m getting :

Permission Denial: reading com.android.externalStorageProvider uri content://com… requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
victorrikcommented, Feb 14, 2021

exist another post about this, recently i found this packages as alternative to rn-fetch-blob

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

it works for me

4reactions
vonovakcommented, Feb 10, 2021

hello @Saidfatah

its really annoying that we have to deal with this

you’re more than welcome to investigate this and open a PR with a fix, it’ll be appreciated, thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Permission Denial Error when trying to ... - Stack Overflow
I'm trying to upload an xlsx to firestore storage ,I'm using react-native-document-picker to pick the file from ExternalStorageDirectoryPath so ...
Read more >
[storage/unknown] Permission Denial | React Native Tutorial
Error : [ storage /unknown] Permission DenialPermission Denial Error when trying to upload file picked from ExternalStorageDirectoryPath to ...
Read more >
Permission Denial Error when trying to upload file picked with ...
Coding example for the question Permission Denial Error when trying to upload file picked with [react-native-document-picker] to fireStore storage-React ...
Read more >
Cloud Storage for Firebase - Google
Developers use the Firebase SDKs for Cloud Storage to upload and download files directly from clients. If the network connection is poor, the...
Read more >
Uploading Files and Images to Firebase Cloud Storage in ...
Hi, When i Upload file on android device i get this error: “Permission Denial: reading com.android.providers.media.MediaDocumentsProvider uri content://com.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found