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 2020/08/21 11:46:29 UTC

[GitHub] [cordova-android] FD-DEV-IT opened a new issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

FD-DEV-IT opened a new issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053


   # Bug Report
   
   ## Problem
   
   After update to cordova-android@9.0.0 and cordova cli 10.0.0 access to the local storage via cdvfile://localhost is not possible.
   
   ### What is expected to happen?
   
   Reading jpg file from local storage to display a image preview
   
   
   ### What does actually happen?
   
   cdvfile://localhost/files/sbsdk-plugin-storage/cee8882b-650f-4107-88c3-5f84f90cbf36.jpg 
   
   net::ERR_UNKNOWN_URL_SCHEME
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   
   
   ### Environment, Platform, Device
   
   Cordova Packages:
   
       cli: 10.0.0
           common: 4.0.2
           create: 3.0.0
           lib: 10.0.0
               common: 4.0.2
               fetch: 3.0.0
               serve: 4.0.0
   
   Project Installed Platforms:
   
       android: 9.0.0
       browser: null
   
   Project Installed Plugins:
   
       call-number: 0.0.2
       cordova-android-support-gradle-release: 0.0.2
       cordova-plugin-android-fingerprint-auth: 1.5.0
       cordova-plugin-androidx-adapter: 1.1.1
       cordova-plugin-androidx: 2.0.0
       cordova-plugin-apprate: 1.4.0
       cordova-plugin-battery-status: 2.0.3
       cordova-plugin-camera: 4.1.0
       cordova-plugin-cocoapod-support: 1.3.0
       cordova-plugin-console: 1.1.1-dev
       cordova-plugin-crypto-file: 1.2.1
       cordova-plugin-device: 2.0.3
       cordova-plugin-dialogs: 2.0.2
       cordova-plugin-file-transfer: 1.7.1
       cordova-plugin-file: 6.0.2
       cordova-plugin-firebasex: 10.1.2
       cordova-plugin-globalization: 1.11.0
       cordova-plugin-image-resizer: 1.0.0
       cordova-plugin-inappbrowser: 4.0.0
       cordova-plugin-nativestorage: 2.3.2
       cordova-plugin-network-information: 2.0.2
       cordova-plugin-scanbot-sdk: 4.2.1
       cordova-plugin-splashscreen: 6.0.0
       cordova-plugin-statusbar: 2.4.3
       cordova-plugin-thumbnail: 1.0.0
       cordova-plugin-whitelist: 1.3.4
       cordova.plugins.diagnostic.api-22: 2.3.10-api-22
       phonegap-plugin-barcodescanner: 8.1.0
   
   Environment:
   
       OS: Microsoft Windows 10 Pro 10.0.18363 (18363) (win32 10.0.18363) x64
       Node: v12.18.3
       npm: 6.14.6
   


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

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-android] rutbastoni commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
rutbastoni commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-1057888035


   > After trying many of the solutions on this topic, i just want to share how i solved this problem without adding additional configuration meta tags in the header or config.xml in my case i want to take a picture, preview and upload it to server.
   > 
   > the important thing in the following code sample is "url: window.URL.createObjectURL(imgBlob)," and now i can display the image taken by setting image DOM src.
   > 
   > I hope this helps someone out there ;)
   > 
   > ```
   > resolveFile (imageURI) {
   >       return new Promise((resolve, reject) => {
   >         window.resolveLocalFileSystemURL(imageURI, (fileEntry) => {
   >           fileEntry.file(file => {
   >             const reader = new FileReader()
   >             reader.onloadend = () => {
   >               const imgBlob = new Blob([reader.result], {
   >                 type: file.type
   >               })
   > 
   >               const resData = {
   >                 name: fileEntry.name,
   >                 // url: fileEntry.toInternalURL(), // NO LONGER WORKS
   >                 url: window.URL.createObjectURL(imgBlob),
   >                 blob: imgBlob,
   >                 fileEntry: fileEntry
   >               }
   > 
   >               window.URL.revokeObjectURL(imgBlob)
   > 
   >               resolve(resData)
   >             }
   >             reader.readAsArrayBuffer(file)
   >           }, (error) => {
   >             console.log(error)
   >             reject(error)
   >           })
   >         })
   >       })
   >     }
   > ```
   
   Thank you so much, it works also for us 


-- 
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-android] AKempente edited a comment on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
AKempente edited a comment on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-1010385567


   After trying many of the solutions on this topic, i just want to share how i solved this problem without adding additional configuration meta tags in the header or config.xml in my case i want to take a picture, preview and upload it to server.
   
   the important thing in the following code sample is "url: window.URL.createObjectURL(imgBlob),"
   and now i can display the image taken by setting  image DOM src.
   
   I hope this helps someone out there ;)
   <code>
   resolveFile (imageURI) {
         return new Promise((resolve, reject) => {
           window.resolveLocalFileSystemURL(imageURI, (fileEntry) => {
             fileEntry.file(file => {
               const reader = new FileReader()
               reader.onloadend = () => {
                 const imgBlob = new Blob([reader.result], {
                   type: file.type
                 })
   
                 const resData = {
                   name: fileEntry.name,
                   // url: fileEntry.toInternalURL(), // NO LONGER WORKS
                   url: window.URL.createObjectURL(imgBlob),
                   blob: imgBlob,
                   fileEntry: fileEntry
                 }
   
                 window.URL.revokeObjectURL(imgBlob)
   
                 resolve(resData)
               }
               reader.readAsArrayBuffer(file)
             }, (error) => {
               console.log(error)
               reject(error)
             })
           })
         })
       }
   </code>


-- 
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-android] AKempente commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
AKempente commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-1010385567


   After trying many of the solutions on this topic, i just want to share how i solved this problem without adding additional configuration meta tags in the header or config.xml in my case i want to take a picture, preview and upload it to server.
   
   the important thing in the following code sample is "url: window.URL.createObjectURL(imgBlob),"
   and now i can display the image taken by setting  image DOM src.
   
   I hope this helps someone out there ;)
   
   resolveFile (imageURI) {
         return new Promise((resolve, reject) => {
           window.resolveLocalFileSystemURL(imageURI, (fileEntry) => {
             fileEntry.file(file => {
               const reader = new FileReader()
               reader.onloadend = () => {
                 const imgBlob = new Blob([reader.result], {
                   type: file.type
                 })
   
                 const resData = {
                   name: fileEntry.name,
                   // url: fileEntry.toInternalURL(), // NO LONGER WORKS
                   url: window.URL.createObjectURL(imgBlob),
                   blob: imgBlob,
                   fileEntry: fileEntry
                 }
   
                 window.URL.revokeObjectURL(imgBlob)
   
                 resolve(resData)
               }
               reader.readAsArrayBuffer(file)
             }, (error) => {
               console.log(error)
               reject(error)
             })
           })
         })
       },


-- 
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-android] AKempente edited a comment on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
AKempente edited a comment on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-1010385567


   After trying many of the solutions on this topic, i just want to share how i solved this problem without adding additional configuration meta tags in the header or config.xml in my case i want to take a picture, preview and upload it to server.
   
   the important thing in the following code sample is "url: window.URL.createObjectURL(imgBlob),"
   and now i can display the image taken by setting  image DOM src.
   
   I hope this helps someone out there ;)
   
   ```
   resolveFile (imageURI) {
         return new Promise((resolve, reject) => {
           window.resolveLocalFileSystemURL(imageURI, (fileEntry) => {
             fileEntry.file(file => {
               const reader = new FileReader()
               reader.onloadend = () => {
                 const imgBlob = new Blob([reader.result], {
                   type: file.type
                 })
   
                 const resData = {
                   name: fileEntry.name,
                   // url: fileEntry.toInternalURL(), // NO LONGER WORKS
                   url: window.URL.createObjectURL(imgBlob),
                   blob: imgBlob,
                   fileEntry: fileEntry
                 }
   
                 window.URL.revokeObjectURL(imgBlob)
   
                 resolve(resData)
               }
               reader.readAsArrayBuffer(file)
             }, (error) => {
               console.log(error)
               reject(error)
             })
           })
         })
       }
   ```


-- 
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-android] FD-DEV-IT commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
FD-DEV-IT commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-680845832


   The last version (cordova android@8.0.0 /sdk 28) worked without problems. It looks like the cdvfile:// protocol is no longer recognized


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

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-android] breautek commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-680870465


   > Thanks for your answer. The problem is not the path. Apparently the webview blocks the loading of local graphics into the html img src
   
   You're right, you were using a particular part of the feature that I wasn't really familiar with.
   
   I just tested this on `cordova-android@9` targeting API 29. I have an image file inside `cordova.files.dataDirectory + 'files/test.png';`
   
   Which when I use `toInternalURL()`, it gives me `cdvfile://localhost/persistent/test.png` path. This works when used in the DOM, for as long as I update the CSP appropriately.
   
   For me, my [fs root](https://github.com/apache/cordova-plugin-file#cdvfile-protocol) appears to be `persistent`, while your URL seems to have an fs root of `files`
   
   If I change `persistent` to files, I do not receive the `ERR_UNKNOWN_URL_SCHEME`, but I do get a 404 Not found. I did receive `ERR_UNKNOWN_URL_SCHEME` if I use other `localhost/x` paths.
   
   After moving the test image file to the proper place using `adb shell`, I see the `cdvfile://localhost/files/...` works properly for me.
   
   I then created a sub directory and copied the image file, and determine it still works.
   
   I then changed the `AndroidExtraFileSystems` defaults to omit the `files` file-system using:
   
   `<preference name="AndroidExtraFilesystems" value="files-external,documents,sdcard,cache,cache-external,assets,root" />`
   
   This is when I reproduced your issue. So I would check the `AndroidExtraFilesystems` preference and ensure you are including `files`


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

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-android] FD-DEV-IT edited a comment on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
FD-DEV-IT edited a comment on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-679260944


   Thanks for your answer. The problem is not the path. Apparently the webview blocks the loading of local graphics into the html img src


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

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-android] breautek commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-678262454


   It looks like you took the full file path from another platform and saved it, then tried to use that file path on a different platform.
   
   File paths differ from by platform, so you should be saving the relative URL part, eg:
   
   ```
   localStorage.myImage = "cee8882b-650f-4107-88c3-5f84f90cbf36.jpg";
   
   ...
   
   let  myImage = localStorage.myImage;
   let filepath = cordova.files.dataDirectory + myImage;
   ```
   
   The above example hasn't been tested, but should give you the right idea. Let me know if this helps.


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

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-android] FD-DEV-IT commented on issue #1053: android@9.0.0 and cordova cli 10.0.0 cdvfile://localhost net::ERR_UNKNOWN_URL_SCHEME

Posted by GitBox <gi...@apache.org>.
FD-DEV-IT commented on issue #1053:
URL: https://github.com/apache/cordova-android/issues/1053#issuecomment-679260944


   Thanks for your answer. The problem is not the path. Apparently the webview blocks the loading of graphics into the html img src


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

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