Skip to content

Instantly share code, notes, and snippets.

@noah-hx
noah-hx / OkHttpDownloader.kt
Created December 9, 2020 09:38 — forked from gildor/OkHttpDownloader.kt
Simple non-blocking extension function for OkHttp Call that wraps request to Kotlin Coroutine and saves response to File
import kotlinx.coroutines.experimental.*
import okhttp3.*
import okio.Buffer
import okio.Okio
import java.io.File
import java.io.IOException
/**
* Custom coroutine dispatcher for blocking calls
*/