You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/02/07 08:55:01 UTC

[GitHub] [cordova-plugin-file] weareu opened a new issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

weareu opened a new issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512


   # Bug Report
   Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here. So upgrading to Android 10 template for cordova you can no longer access assets via cvdfile protocol urls still provided by the file plugin. This was previously a  issue with web server based plugins like ionic-cordova-webview and others. But now it is a issue for the standard cordova template.
   
   ## Problem
   Whilst File access remains for our logging, html/browser access via cvdfile is broken. I've seen some attempts here to change from cvdfile protocol but all unsuccessfully merged. Keeping this protocol breaks in Android 10 template, has already caused endless issues with webview plugin and ios removal. Causes CORS issues, etc etc. I know the previous attempts changed the host. This would be wrong due to CORS, but that is a silly excuse to just do nothing. This plugin is basically one for the cornerstone cordova plugins that crosses the bridge for developing non-native/native. Hacky solutions claiming all access should now be javascript is wrong. 
   
   Best solution would be to become compatible with AndroidX and change the file path (if template > 10) to utilize a "virtual folder" for cvd access. It's not breaking any rules if the access is served via the current hosting mechanisms (wether ionic-webview OR Android Template > 10 without enabling legacy file mode). 
   
   I'm going to make this change and pull. Please assist with suggestions.
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   To reproduce. Upgrade Cordova Android > 10. Access assets via cvdfile://.... either by requesting valid url from toNativeURL or toInternalURL. Neither can render either as file: or cvdfile: because you are comming from https.
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   Android Cordova 10 template. Android 11 or below.
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   Ionic:
   
      Ionic CLI         : 6.18.1 (/Users/weareu/.nvm/versions/node/v16.13.1/lib/node_modules/@ionic/cli)
      Ionic Framework   : ionic1 1.3.5
      @ionic/v1-toolkit : 3.2.15
   
   Cordova:
   
      Cordova CLI       : 11.0.0
      Cordova Platforms : android 10.1.1, ios 5.1.1
      Cordova Plugins   : no whitelisted plugins (41 plugins total)
   
   System:
   
      Android SDK Tools : 26.0.1 (/Users/weareu/Library/Android/sdk)
      ios-deploy        : 1.11.4
      ios-sim           : 8.0.2
      NodeJS            : v16.13.1 (/Users/weareu/.nvm/versions/node/v16.13.1/bin/node)
      npm               : 7.24.2
      OS                : macOS Monterey
      Xcode             : Xcode 13.2.1 Build version 13C100
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [X] I searched for existing GitHub issues
   - [X] I updated all Cordova tooling to most recent version
   - [X] 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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] pietos edited a comment on issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
pietos edited a comment on issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512#issuecomment-1048483440


   I had a similar issue as a workaround I load the files into a blob and then attach the blob to the html view.
   First I only had to do this for IOS devices, but since the latest cordova and android updates I use the IOS condition for both Android and IOS.
   
   **Example code**
   
   `// remark: rs.rows.item(0).localsrc; the store result of fileEntry.toInternalURL();
   rs.rows.item(0).localsrc; (which is fileEntry.toInternalURL();)
   
   // On IOS we have to convert the image to a blob
   window.resolveLocalFileSystemURL(rs.rows.item(0).localsrc, function(fileEntry) {
     if (window.cordova.platformId == "ios") {
     fileEntry.file(function(file) {
         var reader = new FileReader();
         reader.onloadend = function() {
             if (reader.result) {
                 var blob = new Blob([new Uint8Array(reader.result)], { type: "image/jpeg" });
                 blob = window.URL.createObjectURL(blob);
                 companylogoimgEL.src = blob;
             } else {
                 companylogoimgEL.src = 'res/' + APP_SELLER + '/logo_horizontal_white_smaller.png';
             }
         };
         reader.readAsArrayBuffer(file);
     });
     // On Android we can just load the local file
     } else {
         companylogoimgEL.src = rs.rows.item(0).localsrc;
     }
   }`


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] weareu commented on issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
weareu commented on issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512#issuecomment-1048601753


   This does not work when comming from https on Android or standard Android 10+ because localsrc will be file:// this is no longer allowed.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] erisu closed issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
erisu closed issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512


   


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] pietos commented on issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
pietos commented on issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512#issuecomment-1048483440


   I had a similar issue as a workaround I load the files into a blob and then attach the blob to the html view.
   First I only had to do this for IOS devices, but since the latest cordova and android updates I use the IOS condition for both Android and IOS.
   
   **Example code**
   
   // remark: rs.rows.item(0).localsrc; the store result of fileEntry.toInternalURL();
   rs.rows.item(0).localsrc; (which is fileEntry.toInternalURL();)
   
   // On IOS we have to convert the image to a blob
   window.resolveLocalFileSystemURL(rs.rows.item(0).localsrc, function(fileEntry) {
     if (window.cordova.platformId == "ios") {
     fileEntry.file(function(file) {
         var reader = new FileReader();
         reader.onloadend = function() {
             if (reader.result) {
                 var blob = new Blob([new Uint8Array(reader.result)], { type: "image/jpeg" });
                 blob = window.URL.createObjectURL(blob);
                 companylogoimgEL.src = blob;
             } else {
                 companylogoimgEL.src = 'res/' + APP_SELLER + '/logo_horizontal_white_smaller.png';
             }
         };
         reader.readAsArrayBuffer(file);
     });
     // On Android we can just load the local file
     } else {
         companylogoimgEL.src = rs.rows.item(0).localsrc;
     }
   }


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] weareu edited a comment on issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
weareu edited a comment on issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512#issuecomment-1048601753


   This does not work when comming from https on Android or standard Android 10+ because localsrc will be file:// this is no longer allowed. Or am I missing something?


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] pietos commented on issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
pietos commented on issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512#issuecomment-1048609211


   
   
   
   > This does not work when comming from https on Android or standard Android 10+ because localsrc will be file:// this is no longer allowed. Or am I missing something?
   
   I tested it on my pixel 5 phone with android 12 from an external https source without any issues.


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-file] pietos edited a comment on issue #512: Cordova 10 Android Template Serves via Https so cvdfile: webview access also no longer works here

Posted by GitBox <gi...@apache.org>.
pietos edited a comment on issue #512:
URL: https://github.com/apache/cordova-plugin-file/issues/512#issuecomment-1048483440


   I had a similar issue as a workaround I load the files into a blob and then attach the blob to the html view.
   First I only had to do this for IOS devices, but since the latest cordova and android updates I use the IOS condition for both Android and IOS.
   
   **Example code**
   
   ```
   // remark: rs.rows.item(0).localsrc; the store result of fileEntry.toInternalURL();
   rs.rows.item(0).localsrc; (which is fileEntry.toInternalURL();)
   
   // On IOS we have to convert the image to a blob
   window.resolveLocalFileSystemURL(rs.rows.item(0).localsrc, function(fileEntry) {
     if (window.cordova.platformId == "ios") {
     fileEntry.file(function(file) {
         var reader = new FileReader();
         reader.onloadend = function() {
             if (reader.result) {
                 var blob = new Blob([new Uint8Array(reader.result)], { type: "image/jpeg" });
                 blob = window.URL.createObjectURL(blob);
                 companylogoimgEL.src = blob;
             } else {
                 companylogoimgEL.src = 'res/' + APP_SELLER + '/logo_horizontal_white_smaller.png';
             }
         };
         reader.readAsArrayBuffer(file);
     });
     // On Android we can just load the local file
     } else {
         companylogoimgEL.src = rs.rows.item(0).localsrc;
     }
   }
   ```


-- 
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: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org