File tree Expand file tree Collapse file tree
src/main/java/com/nitrofs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,8 +138,9 @@ dependencies {
138138 implementation project(" :react-native-nitro-modules" )
139139
140140 // Add a dependency on NitroFS
141- implementation(" io.ktor:ktor-client-core:2.3.2" )
142- implementation(" io.ktor:ktor-client-okhttp:2.3.2" )
141+ var ktor_version = " 3.1.3"
142+ implementation(" io.ktor:ktor-client-core:$ktor_version " )
143+ implementation(" io.ktor:ktor-client-okhttp:$ktor_version " )
143144}
144145
145146if (isNewArchitectureEnabled()) {
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ class FileDownloader {
2727 client.use { it
2828 it.prepareGet(" $serverUrl /$fileName " ) {
2929 method = HttpMethod .Get
30- onDownload { bytesSentTotal , contentLength ->
31- if (bytesSentTotal > 0 ){
30+ onDownload { totalBytesSent , contentLength ->
31+ if (totalBytesSent > 0 && contentLength != null ){
3232 onProgress?.let {
3333 Handler (Looper .getMainLooper()).post {
34- onProgress.invoke(bytesSentTotal .toDouble(), contentLength.toDouble())
34+ onProgress.invoke(totalBytesSent .toDouble(), contentLength.toDouble())
3535 }
3636 }
3737 }
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ package com.nitrofs
22
33import android.os.Handler
44import android.os.Looper
5+ import io.ktor.client.HttpClient
56import com.margelo.nitro.nitrofs.NitroUploadMethod
67import com.margelo.nitro.nitrofs.NitroUploadOptions
7- import io.ktor.client.HttpClient
88import io.ktor.client.engine.okhttp.OkHttp
99import io.ktor.client.plugins.onUpload
1010import io.ktor.client.request.forms.formData
@@ -42,10 +42,12 @@ class NitroFileUploader {
4242 }
4343 ){
4444 method = getMethod(uploadOptions.method)
45- onUpload { bytesSent, totalBytes ->
46- onProgress?.let {
47- Handler (Looper .getMainLooper()).post {
48- it.invoke(bytesSent.toDouble(), totalBytes.toDouble())
45+ onUpload { totalBytesSent, totalBytes ->
46+ if (totalBytesSent > 0 && totalBytes != null ) {
47+ onProgress?.let {
48+ Handler (Looper .getMainLooper()).post {
49+ it.invoke(totalBytesSent.toDouble(), totalBytes.toDouble())
50+ }
4951 }
5052 }
5153 }
You can’t perform that action at this time.
0 commit comments