Open moltenice opened 3 years ago
https://github.com/digaus/capacitor-community-filesystem
I made a dirty workaround. Works for my project so far. Better would be if we could somehow register the electron part to the original Filesystem Plugin.
Any idea if this would be doable somehow @IT-MikeS? Just pulling the definitions from @capacitor/filesystem
and then register the electron part from @capacitor-community/filesystem
to it?
That way would could implement @capacitor-community
electron versions for the capacitor maintained plugins.
I have a plugin like node:fs
for capacitor hope it helps you!
https://github.com/digaus/capacitor-community-filesystem
I made a dirty workaround. Works for my project so far. Better would be if we could somehow register the electron part to the original Filesystem Plugin.
Any idea if this would be doable somehow @IT-MikeS? Just pulling the definitions from
@capacitor/filesystem
and then register the electron part from@capacitor-community/filesystem
to it?That way would could implement
@capacitor-community
electron versions for the capacitor maintained plugins.
Thanks for sharing this, I will take a look.
So in general most Ionic/Capacitor plugins will not work with "@capacitor-community/electron" by default? It seems so strange that accessing the filesystem is highly unsupported cross platform here. Especially when a Cordova plugin exists and would work: https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-file/
For some reason the Ionic wrapper doesn't work for Electron.
I have a plugin like
node:fs
for capacitor hope it helps you!
Would this work on Android as well?
Tôi có một plugin như
node:fs
cho tụ điện hy vọng nó sẽ giúp bạn! https://npmjs.org/package/capacitor-fsĐiều này cũng sẽ hoạt động trên Android?
Yes, this plugin working on all platform.
Thank you very much @digaus and @tachibana-shin for your solutions! They will help me solve this issue :)
Hopefully an official Filesystem solution shows up for capacitor-community/electron
at some point.
My requirement is similar to that of the OP: I want to target Android and Desktop, but I don't need arbitrary access to the whole filesystem. I only want files saved on disk, and it doesn't matter where.
This is the dummy code I'm using:
await Filesystem.writeFile({
path: 'test.json',
data: JSON.stringify("hello world"),
directory: Directory.Documents,
encoding: Encoding.UTF8,
})
If they are saved to disk, I can't find where. Could that be documented?
If they aren't, what would it take to be able to use the @capacitor/filesystem
module and save files to disk? I've looked at the capacitor-fs
plugin that was previous posted here, but I much prefer the API of the core FS module.
My requirement is similar to that of the OP: I want to target Android and Desktop, but I don't need arbitrary access to the whole filesystem. I only want files saved on disk, and it doesn't matter where.
This is the dummy code I'm using:
await Filesystem.writeFile({ path: 'test.json', data: JSON.stringify("hello world"), directory: Directory.Documents, encoding: Encoding.UTF8, })
If they are saved to disk, I can't find where. Could that be documented?
If they aren't, what would it take to be able to use the
@capacitor/filesystem
module and save files to disk? I've looked at thecapacitor-fs
plugin that was previous posted here, but I much prefer the API of the core FS module.
Oh I'll tell you where they'll be saved on Android:
Directory.Documents
: /sdcard/Documents/
-- you will see dir Documents
as soon as you enter the file manager
Directory.Cache
: /data/cache
-- required root permission
If you use Directory.Documents as a path on a desktop (Windows 10 and Chrome). Where are the files saved? I notice that it is updated with data but I can't find it on the disk.
If you use Directory.Documents as a path on a desktop (Windows 10 and Chrome). Where are the files saved? I notice that it is updated with data but I can't find it on the disk.
I also join the question
I found out that the files saved with
await Filesystem.writeFile ({ path: 'AAAAtext222.txt', data: 'This is a test', directory: Directory.Documents, encoding: Encoding.UTF8, });
in the electron assembly for winodws 10
Save to IndexedDB
I would like to save the files in the root of the program, so where exe. Who knows how?
I added a pull-request to the default Capacitor plugins repo that adds support for Electron to the Filesystem plugin: https://github.com/ionic-team/capacitor-plugins/pull/792
If you use Directory.Documents as a path on a desktop (Windows 10 and Chrome). Where are the files saved? I notice that it is updated with data but I can't find it on the disk.
I also join the question
I found out that the files saved with
await Filesystem.writeFile ({ path: 'AAAAtext222.txt', data: 'This is a test', directory: Directory.Documents, encoding: Encoding.UTF8, });
in the electron assembly for winodws 10
Save to IndexedDB
I would like to save the files in the root of the program, so where exe. Who knows how?
Hi mate @NeluQi! Did you find where the files are stored finally?
What's the recommended approach for an Ionic+Capacitor app to access the filesystem via Electron?
There's a couple of options:
But none of them allow me to access for example my home directory
~
.With pure Electron I can just use
fs
but that's not an option here as I'd like it to work with Android as well.A recommended approach and perhaps a code example would be really appreciated as the current docs are only focused on iOS and Android for these plugins.