Giter Site home page Giter Site logo

Comments (9)

tobiasmuecksch avatar tobiasmuecksch commented on April 27, 2024 3

I found a solution / workaround.

I'm now converting content:// URLs to file:// with the following plugin:

https://ionicframework.com/docs/native/file-path

from capacitor-plugins.

jcesarmobile avatar jcesarmobile commented on April 27, 2024

can you provide a sample app?

from capacitor-plugins.

ThomasKientz avatar ThomasKientz commented on April 27, 2024

@jcesarmobile I made further tests. Crash only occurs with paths starting content://. I got those paths from an intent (https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent#intentshimonintent)

Here is a sample app :
https://github.com/ThomasKientz/capacitor-fs-issue-repro

from capacitor-plugins.

jcesarmobile avatar jcesarmobile commented on April 27, 2024

Yeah, content urls are only supported by readFile at the moment because they are not regular filesystem url, they belong to other app and you can't do Filesystem tasks on another app file, other than reading it if it was shared, and maybe stat could be implemented with a lot of content resolver code.
But should definitely not crash.

from capacitor-plugins.

ThomasKientz avatar ThomasKientz commented on April 27, 2024

I have created a plugin to read a file's name and size from a content uri : https://github.com/ThomasKientz/capacitor-plugin-file-infos

Would be nice to implement it inside FS plugin imo !

from capacitor-plugins.

tobiasmuecksch avatar tobiasmuecksch commented on April 27, 2024

Same issue with the copyFile method. Works perfectly on iOS but not on Android....

from capacitor-plugins.

jcesarmobile avatar jcesarmobile commented on April 27, 2024

This issue is about content urls, that's an android thing, so can't work on iOS.
If you mean copyFile doesn't work on Android, report a new issue and provide more information.

from capacitor-plugins.

tobiasmuecksch avatar tobiasmuecksch commented on April 27, 2024

What I mean is, that Filesystem.copy()doesn't work with content:// urls too. This issue doesn't only effect the Filesystem.stat() method.
My iOS comment is about my expectation, that I can use the same Ionic-App-code for android and iOS. That means passing a Filesystem URI (which I got by some plugin) to any of the FileSystem plugin methods and the Filesystem plugin just does it's magic as it is supposed too. But as often, I have to provide some extra code for Android.... As far as I can tell, in order to copy a file from a content:// URI I'd have to read the file as base64 and then write it to the data-directory for example. That is tremendous overhead which I'd feel very uncomfortable with. Is there any other way?

from capacitor-plugins.

tobiasmuecksch avatar tobiasmuecksch commented on April 27, 2024

I think important information like that, should be displayed way more prominent in the docs. The current hint is not sufficiently clear at all.

Additionally, the Filesystem API supports using full file:// paths, or reading content:// files on Android. Simply leave out the directory param to use a full file path.
Source: https://capacitorjs.com/docs/apis/filesystem#understanding-directories-and-files

from capacitor-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.