-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
filewriter always throws error code 2 #577
Comments
file.removeFile(dir,name) throws permission error: FileError {code: 6, message: 'NO_MODIFICATION_ALLOWED_ERR'} Is this fixable with the READ_MEDIA_IMAGES permission somehow? I Can access files with the READ-permission but it seems like removing and writing files is a problem on Android 13. Any ideas? I would be glad for any help. Thank you! |
PR #581 really only fixes the plugin by removing the request attempt on API 33+ for the obsolete It assumes Instead, apps is suppose to use the I've wrote a pretty large comment elsewhere that explains the nuances with interfacing the file plugin with the MediaStore API. TL;DR; I don't think it's feasible and if you require write access to third-party files, then you'll probably need a separate plugin that interfaces with the MediaStore API. |
@breautek thanks for all your help. I see that you are very active in a few plugins. highly appreciate! |
Thanks for the detailed clarifications! I was part of this Android 13 conversation here too some weeks ago when I created a PR to fix Read permissions. This solved it at least for reading images in the gallery for me. I saw that it got merged. Still I noticed it is not the full solution and at this time I knew you were all waiting for cordova-android 12 which is finally here! I Just saw today that there is cordova-android 12 and the update on this plugin and im happy that it is still maintained by the community and you. Unfortunately as I see now, Android is only allowing read-permissions to external storage with the normal file-system as you described in your post. I will give this plugin another try https://github.com/apache/cordova-plugin-file/issues/cordova-plugin-saf-mediastore. Thank you for all the research! |
I still need to do more research on the implications on removing support for external storage when it comes to other plugins like the camera plugin that kinda uses external storage to some fashion (not that the file plugin works well to begin with in this area) but I feel like removing external support on the file plugin is going to end up being the best path forward, which leaves the file plugin purely for internal storage only, which still has a fully functional filesystem API on Android. For use cases involving external storage, a different plugin will work much better, since it can have an API more tailored to the MediaStore interface, like the Once I understand what kind of problems will arise to dependent Apache plugins if the external storage support is removed, I'll open a topic on the Dev Mailing List for a more formal community vote on the subject, since it will be a fairly large change. Only thing is... I don't use any external storage stuff at my day job, so I don't have much of an excuse to do allocate work time on this. So this is strictly volunteer time on my part, and well lately I've been pretty burnt out. |
Even I am facing similar issue. It throws error code 2 while downloading the image/pdf file. It is failing while executing getDirectory command from DirectoryEntry.js (cordova-plugin-file) when targeted android API level to 33. I have also included required permissions in config.xml
Any solutions for this is appreciated. Thanks in advance !! |
@Krantikc try to add logs and to see in log cat.
or here:
please make sure you have those changes (for the write permission). try remove ing the plugin and add it from my fork, i tried on few devices android 10-13 and all works. |
@EYALIN Thanks a lot for quick reply, it's working fine. My bad, after importing your forked repo, issue was resolved, but file was not opening up because of cordova-plugin-file-opener2 plugin. I was getting NOT_FOUND error, as there was mismatch in file protocol, whose way handling has been changed as part of cordova-plugin-file-opener2@7.0.0. Thanks Again !! :) |
@NAMUS09 @Krantikc no problem :-) generally, you can use all my community Cordova plugins, I maintain them each time there is an update and expand some of them to support more features. |
Thanks! @EYALIN https://github.com/EYALIN/cordova-plugin-file.git worked when i tried to write to cordova.file.externalRootDirectory + "Pictures/test/" But i get error 2 (security error) when i try to read the files and list them cordova.file.externalRootDirectory + "Pictures/test/" Any help would be great |
This issue is major blocker for us as our apps are build using CI/CD pipelines and there's no way to patch it in run time builds. |
Because Apache Cordova is entirely driven by volunteers providing contributions on their free time, we can't really give any meaningful estimates. PR #581 requires changes and currently we are giving time for the OP to make those changes. If the OP happens to make those changes it may move quicker, otherwise someone will have to (volunteerly) pull the and rebase the fork and make any required changes necessary. Should someone take the fork and rebase it, it's important to rebase it in such a way that the original author commit is left in tact so that credit is provided to the original author. |
Should be resolved by #608 |
Bug Report
when writing file in this path " window.cordova.file.externalRootDirectory + 'Download' " always throws error in filewriter.onerror. Issue not there in cordova v11, cordova-android v11 and cordova-plugin-file v7.
Problem
What is expected to happen?
It should write the file and return success.
What does actually happen?
throws error code 2
Information
tying to save pdf in download folder. I tried updating the plugin file to v8. Still issue is there.
Command or Code
private writeToFile(pdfData: BlobPart, fileName: string): Promise {
return new Promise((resolve, reject) => {
var storageLocation = '';
}
Environment, Platform, Device
while targeting to api 33 issue occurs. There is no issue in cordova v11 ,cordova-android v11 and cordova-plugin-file v7 targeting to api 32.
Version information
Cordova CLI v12,
Cordova-android v12
Cordova v8, v7 (both tested)
Checklist
The text was updated successfully, but these errors were encountered: