start migration onto ktor 3.0

This commit is contained in:
InsanusMokrassar 2024-10-10 21:53:26 +06:00
parent 24bd403549
commit fce7ec8912
5 changed files with 10 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[versions] [versions]
kt = "2.0.20" kt = "2.0.21"
kt-serialization = "1.7.3" kt-serialization = "1.7.3"
kt-coroutines = "1.9.0" kt-coroutines = "1.9.0"
@ -15,7 +15,7 @@ sqlite = "3.46.1.3"
korlibs = "5.4.0" korlibs = "5.4.0"
uuid = "0.8.4" uuid = "0.8.4"
ktor = "2.3.12" ktor = "3.0.0"
gh-release = "2.5.2" gh-release = "2.5.2"

View File

@ -3,9 +3,10 @@ package dev.inmo.micro_utils.ktor.client
import dev.inmo.micro_utils.common.MPPFile import dev.inmo.micro_utils.common.MPPFile
import dev.inmo.micro_utils.ktor.common.* import dev.inmo.micro_utils.ktor.common.*
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.content.*
expect suspend fun HttpClient.tempUpload( expect suspend fun HttpClient.tempUpload(
fullTempUploadDraftPath: String, fullTempUploadDraftPath: String,
file: MPPFile, file: MPPFile,
onUpload: OnUploadCallback = { _, _ -> } onUpload: ProgressListener = { _, _ -> }
): TemporalFileId ): TemporalFileId

View File

@ -5,6 +5,7 @@ import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.micro_utils.ktor.common.TemporalFileId import dev.inmo.micro_utils.ktor.common.TemporalFileId
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.content.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.w3c.dom.mediasource.ENDED import org.w3c.dom.mediasource.ENDED
import org.w3c.dom.mediasource.ReadyState import org.w3c.dom.mediasource.ReadyState
@ -14,7 +15,7 @@ import org.w3c.xhr.XMLHttpRequest.Companion.DONE
suspend fun tempUpload( suspend fun tempUpload(
fullTempUploadDraftPath: String, fullTempUploadDraftPath: String,
file: MPPFile, file: MPPFile,
onUpload: OnUploadCallback onUpload: ProgressListener
): TemporalFileId { ): TemporalFileId {
val formData = FormData() val formData = FormData()
val answer = CompletableDeferred<TemporalFileId>(currentCoroutineContext().job) val answer = CompletableDeferred<TemporalFileId>(currentCoroutineContext().job)
@ -60,5 +61,5 @@ suspend fun tempUpload(
actual suspend fun HttpClient.tempUpload( actual suspend fun HttpClient.tempUpload(
fullTempUploadDraftPath: String, fullTempUploadDraftPath: String,
file: MPPFile, file: MPPFile,
onUpload: OnUploadCallback onUpload: ProgressListener
): TemporalFileId = dev.inmo.micro_utils.ktor.client.tempUpload(fullTempUploadDraftPath, file, onUpload) ): TemporalFileId = dev.inmo.micro_utils.ktor.client.tempUpload(fullTempUploadDraftPath, file, onUpload)

View File

@ -4,6 +4,7 @@ import dev.inmo.micro_utils.common.MPPFile
import dev.inmo.micro_utils.common.filename import dev.inmo.micro_utils.common.filename
import dev.inmo.micro_utils.ktor.common.TemporalFileId import dev.inmo.micro_utils.ktor.common.TemporalFileId
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.content.*
import io.ktor.client.plugins.onUpload import io.ktor.client.plugins.onUpload
import io.ktor.client.request.forms.formData import io.ktor.client.request.forms.formData
import io.ktor.client.request.forms.submitFormWithBinaryData import io.ktor.client.request.forms.submitFormWithBinaryData
@ -18,7 +19,7 @@ internal val MPPFile.mimeType: String
actual suspend fun HttpClient.tempUpload( actual suspend fun HttpClient.tempUpload(
fullTempUploadDraftPath: String, fullTempUploadDraftPath: String,
file: MPPFile, file: MPPFile,
onUpload: OnUploadCallback onUpload: ProgressListener
): TemporalFileId { ): TemporalFileId {
val inputProvider = file.inputProvider() val inputProvider = file.inputProvider()
val fileId = submitFormWithBinaryData( val fileId = submitFormWithBinaryData(

View File

@ -18,7 +18,7 @@ internal val MPPFile.mimeType: String
actual suspend fun HttpClient.tempUpload( actual suspend fun HttpClient.tempUpload(
fullTempUploadDraftPath: String, fullTempUploadDraftPath: String,
file: MPPFile, file: MPPFile,
onUpload: OnUploadCallback onUpload: ProgressListener
): TemporalFileId { ): TemporalFileId {
val inputProvider = file.inputProvider() val inputProvider = file.inputProvider()
val fileId = submitFormWithBinaryData( val fileId = submitFormWithBinaryData(