Alex Styl
10/28/2022, 8:22 AMAleksei Tirman [JB]
10/31/2022, 10:58 AMAlex Styl
10/31/2022, 11:07 AMAleksei Tirman [JB]
10/31/2022, 11:12 AMcall.receiveMultipart().forEachPart { part ->
when (part) {
is PartData.FileItem -> {
val input = part.provider()
// Read from input by chunks
}
else -> {}
}
}
Alex Styl
10/31/2022, 11:26 AMforEachPart()
was taking most of the time and the saving the data to file was happening almost instantly. Ill report back whenever I get back to itAlex Styl
11/20/2022, 4:11 AMdebugLn { ">>> 1. Receiving" }
debugLn { ">>> 2. forEach" }
call.receiveMultipart().forEachPart { partData ->
debugLn { ">>> 3. looping" }
when {
partData is PartData.FileItem -> {
uri = run {
debugLn { ">>> 4. running" }
val fileBytes = partData.streamProvider()
val fileName = partData.originalFileName.orEmpty()
debugLn { ">>> 5. saving" }
saveFileUseCase.saveFile(fileBytes, fileName).also {
debugLn { ">>> 6. saved" }
}
The above snippet prints 1 and 2 almost at the same time. Then 3 will be printed after the file is sent to the server. (I see the uploading progress on the client reaching 100% before 3. is hit).
(debugln = println)Alex Styl
11/20/2022, 4:12 AM