Skip to content

Latest commit

 

History

History
82 lines (56 loc) · 5.52 KB

fetcher.md

File metadata and controls

82 lines (56 loc) · 5.52 KB

Fetcher

Translations: 简体中文

Fetcher is used to get data from uri, return FetchResult, and hand it over to Decoder for use.

Each uri supported by Sketch has a corresponding Fetcher implementation, as shown in the following table:

URI Fetcher Create Dependent modules Android iOS Desktop Web
http://, https:// HurlHttpUriFetcher - sketch-http-hurl
http://, https:// OkHttpHttpUriFetcher - sketch-http-okhttp
http://, https:// KtorHttpUriFetcher - sketch-http-ktor3
file://, / FileUriFetcher newFileUri() -
file:///compose_resource/ ComposeResourceUriFetcher newComposeResourceUri() sketch-compose-resources
data:image/, data:img/ Base64UriFetcher newBase64Uri() -
file:///android_asset/ AssetUriFetcher newAssetUri() -
content:// ContentUriFetcher - -
android.resource:// ResourceUriFetcher newResourceUri() -
app.icon:// AppIconUriFetcher newAppIconUri() sketch-extensions-appicon
file:///kotlin_resource/ KotlinResourceUriFetcher newKotlinResourceUri() -

Important

The above components all support automatic registration. You only need to import them without additional configuration. If you need to register manually, please read the documentation: 《Register component》

Extend Fetcher

First implement the Fetcher interface to define your Fetcher and its Factory

Then refer to the document 《Register component》 to register your Fetcher