bug: Ask permission when using Filesystem.readFile or add permission into the Permission plugin
See original GitHub issueBug Report
Capacitor Version
Latest Dependencies:
@capacitor/cli: 2.4.0 @capacitor/core: 2.4.0 @capacitor/android: 2.4.0 @capacitor/electron: 2.4.0 @capacitor/ios: 2.4.0
Installed Dependencies:
@capacitor/electron not installed @capacitor/cli 2.2.0 @capacitor/core 2.2.0 @capacitor/android 2.2.0 @capacitor/ios 2.2.0
[success] Android looking great! 👌 Found 4 Capacitor plugins for ios: @capacitor-community/fcm (1.0.8) @capacitor-community/firebase-analytics (0.2.0) @capacitor-community/media (1.0.1) cordova-plugin-camera (4.1.0) [success] iOS looking great! 👌
Platform(s)
iOS
Current Behavior
When reading a file using the Filesystem plugin I am getting a permission issue. I can’t find a solution
Expected Behavior
Prompt for permission when using the Filesystem plugin or add an extra functionality to do this in capacitor Permission plugin
Code Reproduction
When calling await Filesystem.readFile({ path })
I am receiving:
[error] - Error: Uncaught (in promise): Error: The file “123.MOV” couldn’t be opened because you don’t have permission to view it.
Other Technical Details
none
Additional Context
Is there a quick workaround for this issue I could implement now?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
I’m having this very same issue today.
While using the @ionic/camera (cordova-plugin-camera) within a capacitor app and reading a video from the library, it states:
The file “filename.ext” couldn’t be opened because you don’t have permission to view it.
.Reading image files from library with the exact same plugin is actually working perfectly, I suspect due the the following difference;
The file is compressed (trimmed as iOS calls it) by cordova-plugin-camera and it looks like the directory is outside app scope:
This is an example of a trimmed file which is somehow unreachable by the app:
file:///private/var/mobile/Containers/Data/PluginKitPlugin/29878464-6445-4365-8689-FCE4915154EA/tmp/trim.379A14E0-5AB7-4536-89BA-FA82008DF56E.MOV
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.