hfhbd
03/31/2026, 1:17 PMpost {
val part = call.receiveMultipart().asFlow().single()
require(part is PartData.FileItem)
val bytes = ByteArray(part.headers[ContentLength]!!.toInt())
try {
part.provider().readFully(bytes)
} finally {
part.dispose()
}
}
I always get an closed ByteReadChannel.hfhbd
03/31/2026, 4:21 PMasFlow().single() because the body of the PartData is already closed. IMHO in that case you should not expose asFlow(), and PartData should be AutoCloseablesimon.vergauwen
03/31/2026, 4:57 PMconsumeAsFlow.hfhbd
03/31/2026, 5:03 PMforEachPart but exposing a Flow could be questioned. Or add a warning that the body is only available inside the flow, because the flow terminates when readPart() returns null and readPart() returns null when the request is fully consumed...andylamax
04/01/2026, 12:28 AM