Skip to main content
filekit-coil lets Coil 3 load a PlatformFile directly, so you can pass a picked file to AsyncImage as its model.

Usage

Register PlatformFile support once, in your root composable:
Then use a PlatformFile as the model:
If you build your own ImageLoader instead of the singleton, call addPlatformFileSupport() in its components block.

Load files that need security-scoped access

Coil reads the file itself, without the security-scoped access FileKit starts around its own operations. Call securelyAccessFile from onState when the file comes from:
  • the file or directory picker on iOS, which return files outside your app’s sandbox;
  • a bookmark restored on iOS, or on macOS (native or JVM) when the app is sandboxed.
It starts access when loading begins and stops it on success or error. You don’t need it for gallery and camera results (on iOS, FileKit writes them into your app’s temporary or cache folder), for files in your app directories, or on Android and the web. Elsewhere it is a no-op, so calling it from common code is safe.