question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Ask permission when using Filesystem.readFile or add permission into the Permission plugin

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
spasmacommented, Sep 7, 2020

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

0reactions
ionitron-bot[bot]commented, Nov 11, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ios - Capacitor - Filesystem.readFile fails due to missing ...
I want to open a file in my app using the share functionality (I try to share the file directly from the file...
Read more >
Swift file reading permission error on macOS sandbox
I'm trying to read the contents of a file on the filesystem in a macOS Swift app (Xcode 9 / Swift 4). I'm...
Read more >
Capacitor 3.3.2 - File permission issues crashing app : r/ionic
I am trying to use file storage to read in files from the camera or photo library. Upon applying the selected camera photo...
Read more >
Filesystem Capacitor Plugin API | Capacitor Documentation
Request read/write permissions. Required on Android, only when using Directory.Documents or Directory.ExternalStorage . Returns: Promise<PermissionStatus>.
Read more >
The File System Access API: simplifying access to local files
If permission to write hasn't been granted, the browser prompts the user for permission. If permission isn't granted, createWritable() throws a DOMException , ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found