coil-kt/coil

Support saving images to the origin private file system on Js and wasmJs.

Open

#1,951 opened on 2023年12月13日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Kotlin (757 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (11,779 stars)
PR merge metrics
 (平均マージ 20h 14m) (30d で 28 merged PRs)

説明

This is out of date. See below.

Is your feature request related to a problem? Please describe. One of the downsides of running Kotlin Multiplatform code on browser-based Javascript is that it's not possible to read from or write to the device's file system. Currently, that means NetworkFetcher can't cache images on disk and can only store them in memory.

Describe the solution you'd like Due to the nature of browser-based Javascript, it's not possible to write a FileSystem implementation for Javascript. As such it's not possible to write a Ktor response body to disk. This means we need to write a separate fetcher since we can't rely on Ktor or Okio.

The <img> tag in Javascript has special privileges to write to a disk cache on browsers. Using this tag we may be able to fetch the image data using a hidden <img> tag and then read and wrap its binary data as an ImageSource. Ideally, we would avoid the <img> tag decoding the image into memory, but I'm not sure if that's possible.

Additional context This may or may not happen as there might be blockers or performance issues. I'm not very familiar with the web's APIs and their constraints.

コントリビューターガイド