Hi Ktor client users. I made a file caching librar...
# feed
f
Hi Ktor client users. I made a file caching library. The only one available is for JVM, so I made one multiplatform. As usual, feedback is welcome. https://github.com/frankois944/KtorKMPFileCaching
🚀 7
kodee loving 1
kodee happy 2
m
I think the missing ones for wasmJs and js browser could be easily implemented via the LocalStorage API defined in https://github.com/Kotlin/kotlinx-browser if I haven’t misunderstood what you did. I have recently implemented something like this for a similar purpose.
f
I can see what I can do about that, okio doesn’t support well these targets.
The LocalStorage in Wasm/kotlinJS is not enough, there are missing methods/capability like getting the list of item inside the storage (aka getting the content of a directory), it could be done in full JS, but I need to do some tricky stuff. I prefer to wait a better support.
m
I solved that by creating my own table of contents which I serialize into a JSON file beside all the other files. Would you be interested in the code? I could send you a link.
f
storing an index which represents the stored file can do the job. Anyway, this approach is totally different than okio and my implementation is on based on it. I need to rework my library
s
Late to the party, but you can merge all other targets into a new okioMain target, then implement the web (js and wasm) separately (probably could also be in a single webMain target) may require adding some custom types where you normally used Okio stuff, but yeah, it all depends on how tightly coupled your API surface is to Okio specifics.
One other thing is probably just implementing the FileSystem interface in Okio? I'm on mobile, can't check the details, but it would be cool if that would make it possible to abstract over a custom file system like what @Michael Paus mentioned.
f
I have already done my rework, currently separately and it’s working. But I need to merge my targets to make my projet cleaner.
🙌 1
s
Best of luck!