-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cordova 11 Android throwing FileError Code 12 trying to access fileSystem #560
Comments
Android's scoped storage forbids creating custom directories in external storage root and some other directories. Scoped storage is enforced on all API 29 devices and later. Additionally, API 29 SDK lacks the FileSystem API for scoped storage, which effectively breaks this plugin as well as any library that depends on using the Java's File APIs when trying to access the external storage. So instead of using If using the external storage is not a requirement, it may be better to use the internal storage instead (and avoid all the external storage limitations, including the API 29 problem explained above): Let me know if this helps. |
@breautek - thanks for quick response. On both Simulator (Pixel 3a Android 10) and on real Samsung Flip 4 (Android 13) the On both, And changing it from Question: Looking to transition off of cordova-plugin-file-transfer and came across this: https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html - I presume the |
@breautek - a follow up on this. Could use your input. For Android, I cannot write directly to: However for iOS, I am continually perplexed. For iOS I have now used both However, on the device itself, the In my app, I then try to find this new Please help me resolve this. I have spent days on this and am pulling out what little hair I have left. |
Not quite. First I want to make clear of two filesystem concepts that Android has:
Now
For Android, all of the You're pretty much free to create any directory structure inside internal storage without permissions, within your app_id sandbox.
Inside Android API 28 and earlier, your app could do a lot of different things, everywheres on external storage, including messing around with other app's external storage, as long as you had the Android API 29 have made changes to make external storage slightly more secure, which including locking down some directories. Starting with API 30, Android does implement filesystem API for external storage which allows for third-party libraries and native code to access the external storage again, which also "fixes" this plugin so to speak. The scoped storage changes that came in API 29 however still applies. Starting with API 33 (currently not supported),
Android doesn't make clear but they have said that some directories will be inaccessible. Therefore I wouldn't rely on using custom directories in external root, and instead either use your app's internal or external directory. Therefore I'd consider preparing a migration strategy if necessary.
I'm significantly less knowledgable with iOS, and I'm not sure how Hope this knowledge helps somehow. |
@breautek - well after a VERY long time of frustration, I finally found the answer for iOS. Please update the
Yup...THATS IT. What this does is create symlink to everything in the apps documents folder (ie: Unreal....spun my wheels on this one...well....for at least 3 years. Always coming up with some ugly hybrid that was always breaking; esp with each new version of iOS. But again....in all the years of searching for a solution, I never once saw any reference to these keys before. Unreal its not included in any Apache Cordova docs. Actually, there is an OPEN request to document this very thing....its three years old! #392 - in fact, if you do a google search for Sorry, on a bit of rant....mind blowing how this has escaped so many for so long. Now...this makes me wonder....are there similar and/or corresponding setting/preferences in Android that make the apps internal directories available to users to browse so we don't have to depend on |
OMG finally found the answer to my problem on which I have been banging my head on since last 4 days. Thank you so much @rolinger for such a detailed answer, really appreciate your effort. |
Bug Report
Trying to write to localStorage is breaking on Android with Cordova 11.1.0 (cordova-android 11)
Problem
I am using plugin
cordova-plugin-file-downloader
which is essentially a wrapper for other various plugins. My app code worked on Cordova 10 but is now breaking on Cordova 11. I tracked everything down to aFileError Code 12
which implies the system/folder I am trying to write to doesn't exist, can't be created or doesn't have permission, and the error is being generated from thiscordova-plugin-file
plugin.The
cordova-plugin-file-downloader
call is simply:It fails to initialize and immediately throws the FileError code 12. In <= Cordova 10, this same code worked and on Android devices I could navigate to the devices general Documents folder, open the designated
CustomFolderName
folder and view the file. I looked at Cordova 10 cordova-plugin-file fileSystem specs and they look the same as cordova 11 fileSystem specs; this I think this is a bug. Or if it has changed, what should I be using now because I don't am not seeing any differences?What is expected to happen?
Folder created and document written to that folder
What does actually happen?
FileError Code 12 is generated.
Information
Command or Code
Environment, Platform, Device
Windows 10, Android - all devices
Version information
[email protected]
cordova-android@11
[email protected]
Checklist
The text was updated successfully, but these errors were encountered: