Open gonzoMD opened 1 month ago
I don't think this is a bug... but probably an undocumented caveat with the browser implementation.
applicationDirectory
is the directory of your app installation. On iOS/Android, this refers to the read-only directory of your unpacked application bundle. The browser has no direct equivalency of this as your "application" isn't stored locally on disk. Hence why it returns the location origin instead. There is also no HTTP api to list the contents listing your app files for the browser platform so listing browser app files is something that isn't really achievable.
Conceptually, https://localhost
(or whatever what the site address) makes the most sense for applicationDirectory
constant on the browser platform.
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.
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
Checklist