Hey does anyone have some sample code for writing ...
# multiplatform
a
Hey does anyone have some sample code for writing a file using Okio multiplatform? I'm hitting an AI API that generates an image, and I'd like to write it to the filesystem for both Android and iOS. Cache directory is actually fine in this case. Either the docs for Okio are severly lacking in this regard, or I'm really missing something. Anybody got a few bytes to throw my way? Or is there a more canonical KMP way to do something like this?
j
Depending on the platforms you target, you likely will need to use some `expect`/`actual` platform-specific implementations. Okio's
FileSystem
is not available on all targets.
The Android target requires a
Context
reference to interact with the file system, which makes a common API difficult, without a mechanism to inject it. KorIO does this for example.
a
Okay thanks!
143 Views