Skip to content

Instantly share code, notes, and snippets.

View mohdaquib's full-sized avatar

Mohd Aquib mohdaquib

  • Nagarro
  • New Delhi, India
View GitHub Profile
@mohdaquib
mohdaquib / DownloadRequest.kt
Created September 17, 2022 08:32 — forked from PrashamTrivedi/DownloadRequest.kt
Download File with progress indicator, written in Kotlin with Co-routines
suspend fun downloadFile(url: String,
downloadFile: File,
downloadProgressFun: (bytesRead: Long, contentLength: Long, isDone: Boolean) -> Unit) {
async(CommonPool) {
val request = with(Request.Builder()) {
url(url)
}.build()
val client = with(OkHttpClient.Builder()) {
addNetworkInterceptor { chain ->