cordova-plugin-file icon indicating copy to clipboard operation
cordova-plugin-file copied to clipboard

browser: cordova.file.applicationDirectory returns an http:// URL instead of a file:// one

Open gonzoMD opened this issue 1 year ago • 1 comments
trafficstars

Bug Report

Problem

cordova.file.applicationDirectory returns an "http://" URL instead of a "file://" one. Therefore I am unable to list files inside a directory with window.resolveLocalFileSystemURL.

What is expected to happen?

cordova.file.applicationDirectory returns a "file://" URL which I can use further.

What does actually happen?

it offers an "http://" URL and window.resolveLocalFileSystemURL fails with Error 5.

Bildschirmfoto 2024-04-03 um 17 35 09

Information

On my Android device everything works as expected, I get a "file://" URL, which gets properly resolved

Command or Code

I use the Onsen UI framework, but this works with normal html buttons too <ons-button onclick="alert(cordova.file.applicationDirectory)">test</ons-button>

Environment, Platform, Device

Browser platform Safari 17.4.1

Version information

Cordova Packages:

    cli: 12.0.0
        common: 5.0.0
        create: 5.0.0
        lib: 12.0.1
            common: 5.0.0
            fetch: 4.0.0
            serve: 4.0.1

Project Installed Platforms:

    android: 12.0.1
    browser: 7.0.0

Project Installed Plugins:

    cordova-plugin-file: 8.0.1
    cordova-sqlite-evmax-build-free: 0.0.10-dev
    cordova-sqlite-storage: 6.1.0

Environment:

    OS: macOS Sonoma 14.4.1 (23E224) (darwin 23.4.0) x64
    Node: v21.6.1
    npm: 10.2.4

android Environment:

    android:
[=======================================] 100% Fetch remote repository...       
Available Android targets:
----------
id: 1 or "android-33"
     Name: Android API 33, extension level 3
     Type: Platform
     API level: 33
     Revision: 3
----------
id: 2 or "android-34"
     Name: Android API 34, extension level 7
     Type: Platform
     API level: 34
     Revision: 2


Project Setting Files:

    config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.rnaumann.schwalbenshop" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Schwalbenshop</name>
    <description>Sample Apache Cordova App</description>
    <author email="[email protected]" href="https://cordova.apache.org">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
     <icon src="swallow.png" />
</widget>

    package.json:
--- Start of Cordova JSON Snippet ---
{
  "platforms": [
    "browser",
    "android"
  ],
  "plugins": {
    "cordova-sqlite-evmax-build-free": {},
    "cordova-sqlite-storage": {},
    "cordova-plugin-file": {
      "ANDROIDX_WEBKIT_VERSION": "1.4.0"
    }
  }
}
--- End of Cordova JSON Snippet ---

Checklist

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

gonzoMD avatar Apr 03 '24 15:04 gonzoMD