Can anybody tell me how to read/write a file in a ...
# compose-web
m
Can anybody tell me how to read/write a file in a browser based multiplatform Compose application. I am using Okio for the other platforms but that does not seem to work in a browser although it does support JS. Note: I am not talking about accessing the users local file system. I just need to cache some files locally over multiple sessions inside the browsers sandbox. (I have to admit that I know next to nothing about browser work, so please bear with me.)
b
No idea what to suggest here for browser workflows, but thought I'd clarify that okio js artefact is tailored for nodejs usage - i.e. direct file access on host system
m
Yes, thank you. That’s what I also found out the hard way after implementing an early test case.
c
Yeah, I don’t think you’ll be able to use Okio for direct filesystem access, you’d have to use one of the browser’s APIs for managing cache data, such as Filesystem, IndexedDB, Cache, or Local/Session Storage
m
That FileSystem looks promising but for my initial testing I found the FakeFileSystem sufficient. That pure memory based file system also works in the browser and is sufficient for me at the moment.
s
just need to cache some files locally over multiple sessions
Try this https://github.com/russhwolf/multiplatform-settings
m
Yes, that also looks like a possible solution for now although it would require some redesign on my part. I have to look at it a bit closer.