Skip to content
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

bug: convertFileSrc does not work with Filesystem #3840

Closed
roblouie opened this issue Nov 21, 2020 · 2 comments
Closed

bug: convertFileSrc does not work with Filesystem #3840

roblouie opened this issue Nov 21, 2020 · 2 comments

Comments

@roblouie
Copy link

roblouie commented Nov 21, 2020

Bug Report

Capacitor Version

Capacitor Doctor

Latest Dependencies:

  @capacitor/cli: 2.4.3
  @capacitor/core: 2.4.3
  @capacitor/android: 2.4.3
  @capacitor/electron: 2.4.3
  @capacitor/ios: 2.4.3

Installed Dependencies:

  @capacitor/ios not installed
  @capacitor/cli 2.4.3
  @capacitor/core 2.4.3
  @capacitor/android 2.4.3
  @capacitor/electron not installed

[success] Android looking great! �

Platform(s)

Android

Current Behavior

Using image files saved via Filesystem as img src attributes is not possible. Following the documentation simply results in a "404 (OK)" error, and no file loads. Logcat also states: Capacitor: Unable to open asset URL: http://localhost/_capacitor_file_/DOCUMENTS/myFile.png

Expected Behavior

I should be able to use image files I've saved as img src per the documentation

Code Reproduction

https://github.com/roblouie/file-src-broken

Other Technical Details

I have verified that the file is saved using file system, i can read it back. I simply cannot use convertFileSrc. Based on errors, it is doing the thing the docs says it does: "must be rewritten as http://localhost/_capacitor_file_/path/to/device/file before being used in the Web View.". The failed request is in that format.

npm --version : 6.14.4

node --version : v13.12.0

pod --version (iOS issues only):

Additional Context

There's an open issue here with discussion: ionic-team/cordova-plugin-ionic-webview#380
Nothing really seemed to help me there though.

@jcesarmobile
Copy link
Member

You are using web version of the plugin, not the native version

instead of import { Filesystem } from "@capacitor/core"; use

import { Plugins } from "@capacitor/core";
const { Filesystem } = Plugins;

@ionitron-bot
Copy link

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants