NitzDKoder opened a new issue #1329:
URL: https://github.com/apache/cordova-android/issues/1329


   **1) Image residing in private path.**
    lFileUrl 
=data/user/0/com.company.stub/files/myfolder/IMG-20210826-204423558thumb.jpg
   
   
   **2)XMLHttpRequest request done from javascript level in cordova based 
android app.**
   
   var xhr = new XMLHttpRequest();
   xhr.open("GET", lFileUrl, true);
   xhr.responseType = "blob";
   xhr.onload = function(e) {
   try {
   }
   
   **3)WebResourceResponse shouldInterceptRequest called.**
   2021-08-26 20:44:34.534 32333-4065/com.company.stub D/SystemWebViewClient:  
shouldInterceptRequest request.getUrl(): 
https://localhost/data/user/0/com.company.stub/files/myfolder/IMG-20210826-204423558thumb.jpg
   
   
https://github.com/apache/cordova-android/blob/015db819aed3f35892d2b6035781ea4bd752149d/framework/src/org/apache/cordova/engine/SystemWebViewClient.java#L423
   
   
https://github.com/apache/cordova-android/blob/015db819aed3f35892d2b6035781ea4bd752149d/framework/src/org/apache/cordova/engine/SystemWebViewClient.java#L95
   
   
   **4)File not found exception seen as its searching in "www/"** 
   
   
https://github.com/apache/cordova-android/blob/015db819aed3f35892d2b6035781ea4bd752149d/framework/src/org/apache/cordova/engine/SystemWebViewClient.java#L112
   
   2021-08-26 20:44:34.537 32333-4065/com.company.stub E/SystemWebViewClient: 
www/data/user/0/com.company.stub/files/myfolder/IMG-20210826-204423558thumb.jpg
   
   **### What is expected to happen?**
   1)private File access should be pass.
   
https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader.InternalStoragePathHandler
   
   
   
   
   
   **### What does actually happen?**
   
   File not found exception seen as 
WebViewAssetLoader.InternalStoragePathHandler is not handled. Suggest how to 
handle raw file access.
   
   
   
   **## Information**
   
   https://bugs.chromium.org/p/chromium/issues/detail?id=1101250
   **Below change works.**
        
   ```
   if(filecaseboolean){ is = new FileInputStream(new File(path));//Imagecase
    }else{
         is = parentEngine.webView.getContext().getAssets().open("www/" + path, 
AssetManager.ACCESS_STREAMING);
    }
   ```
   
   
   
   
   
   **### Version information**
   
   
   Cordova:  Android 10.1.0
   device : android 11  
   app targetsdk : 30 .
   
   **Note:** if `<preference name="AndroidInsecureFileModeEnabled" value="true" 
/>` **everything works fine.**
   
   
   - [ ✓] I searched for existing GitHub issues
   - [ ✓] I updated all Cordova tooling to most recent version
   - [✓ ] I included all the necessary information above
   


-- 
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