mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-16 13:23:49 +00:00
add stream using for multipart
This commit is contained in:
parent
1ee5b4bfd4
commit
eb562d8784
@ -14,9 +14,10 @@ import io.ktor.request.receiveMultipart
|
|||||||
import io.ktor.response.respond
|
import io.ktor.response.respond
|
||||||
import io.ktor.response.respondBytes
|
import io.ktor.response.respondBytes
|
||||||
import io.ktor.routing.Route
|
import io.ktor.routing.Route
|
||||||
|
import io.ktor.util.asStream
|
||||||
|
import io.ktor.util.cio.writeChannel
|
||||||
import io.ktor.util.pipeline.PipelineContext
|
import io.ktor.util.pipeline.PipelineContext
|
||||||
import io.ktor.utils.io.core.Input
|
import io.ktor.utils.io.core.*
|
||||||
import io.ktor.utils.io.core.readBytes
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -182,7 +183,9 @@ suspend fun <T> ApplicationCall.uniloadMultipartFile(
|
|||||||
name.nameWithoutExtension,
|
name.nameWithoutExtension,
|
||||||
".${name.extension}"
|
".${name.extension}"
|
||||||
).apply {
|
).apply {
|
||||||
writeBytes(it.provider().readBytes())
|
outputStream().use { fileStream ->
|
||||||
|
it.provider().asStream().copyTo(fileStream)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"data" -> data = standardKtorSerialFormat.decodeDefault(deserializer, it.provider().readBytes()).optional
|
"data" -> data = standardKtorSerialFormat.decodeDefault(deserializer, it.provider().readBytes()).optional
|
||||||
@ -216,7 +219,9 @@ suspend fun ApplicationCall.uniloadMultipartFile(
|
|||||||
name.nameWithoutExtension,
|
name.nameWithoutExtension,
|
||||||
".${name.extension}"
|
".${name.extension}"
|
||||||
).apply {
|
).apply {
|
||||||
writeBytes(it.provider().readBytes())
|
outputStream().use { fileStream ->
|
||||||
|
it.provider().asStream().copyTo(fileStream)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onCustomFileItem(it)
|
onCustomFileItem(it)
|
||||||
|
Loading…
Reference in New Issue
Block a user