janetcasarez commented on issue #494:
URL: 
https://github.com/apache/cordova-plugin-file/issues/494#issuecomment-922016071


    
     Norman,
   
   Thanks for your quick reply.
     
    Sorry, I should have mentioned it before. I already check permission for 
READ_EXTERNAL_STORAGE.
     
    cordova-plugin-android-permissions 1.1.2
     
    Below is sample code:
     
    I get the alert "has permission". From what I understand 
READ_EXTERNAL_STORAGE is granted by default. You don't need to request it.  I 
still can only read the .png files and not my pattern files.
     
    testPermissions: function () {
           var permissions = cordova.plugins.permissions;
           permissions.hasPermission(permissions.READ_EXTERNAL_STORAGE, 
function (status) {
               if (status.hasPermission) {
                   // Permission has been granted previously, no need to 
request it again.
                   alert("has permission");  // I get this alert
                   //movePatFiles.testfile1();
               } else {
                   var error = function () {
                       // Permission has been denied. This example just logs 
warning, 
                       // make sure to handle this state in your application UI 
- e.g. 
                       // inform your user that you can't open the PDF without 
their permissions or similar.
                       console.warn('External storage permission has been 
denied');
                   };
                    var success = function (status) {
                       if (!status.hasPermission) {
                           // Permission has been denied.
                           error();
                       } else {
                           // Permission has been granted, present the document.
                           //presentDocument();
                           alert("got permission 2");
                           //movePatFiles.testfile1();
                       }
                   };
                    // Request the permission to read files from external 
storage.
                   
permissions.requestPermission(permissions.READ_EXTERNAL_STORAGE, 
movePatFiles.moveSuccess, movePatFiles.moveFail);
               }
           })
       },
   
     
     
   
   ----------------------------------------
    From: "Norman Breau" ***@***.***>
   Sent: Thursday, September 16, 2021 6:10 PM
   To: "apache/cordova-plugin-file" ***@***.***>
   Cc: "janetcasarez" ***@***.***>, "Author" ***@***.***>
   Subject: Re: [apache/cordova-plugin-file] Cannot read files 
undercordova.file.externalRootDirectory for Android 11 (#494)   
   
      
   
   If you're app has the READ_EXTERNAL_STORAGE permission granted, in my 
testing reading from external storage works, however some APIs did not attempt 
to request permission. Reading directories was one of those methods. I have an 
open PR that corrects this specific issue, but not sure if that covers all 
cases for external storage. You can try applying that PR to see if it addresses 
your issue. Note that any app that has been prompted for external storage 
permissions but been previously denied may result in an automatic denial of the 
permission, in which case the user must navigate to the permission settings 
themselves to enable the permission.  
   
   READ_EXTERNAL_STORAGE permission isn't always necessary for reading files in 
external storage, but it is necessary when reading files that doesn't belong to 
your app. I believe anything outside of your application's external data 
directory is considered not own by your app (with the exception of the 
predefined MediaStore containers, which has some special rules).  
   
   —
   You are receiving this because you authored the thread.
   Reply to this email directly, view it on GitHub, or unsubscribe.
   Triage notifications on the go with GitHub Mobile for iOS or Android.  
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to