Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import android.media.MediaScannerConnection
import android.os.Build
import android.os.Environment
import androidx.core.net.toUri
import com.getcapacitor.JSObject
import com.getcapacitor.PermissionState
import com.getcapacitor.Plugin
Expand All @@ -25,7 +26,6 @@ import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import androidx.core.net.toUri

@CapacitorPlugin(
name = "FileTransfer",
Expand Down Expand Up @@ -252,12 +252,18 @@ class FileTransferPlugin : Plugin() {
)
notifyProgress("upload", url, finalStatus, forceUpdate = true)
}


val headersObj = JSObject()
result.data.headers?.entries?.forEach { (key, values) ->
key?.let { headerKey ->
headersObj.put(headerKey, values.firstOrNull() ?: "")
}
}
val response = JSObject().apply {
put("bytesSent", result.data.totalBytes)
put("responseCode", result.data.responseCode)
put("response", result.data.responseBody)
put("headers", result.data.headers)
put("headers", headersObj)
}
call.resolve(response)
}
Expand Down