Is there a way to listen to the progress of a file...
# ktor
a
Is there a way to listen to the progress of a file being uploaded to a ktor server from the server side? I have a ktor server running in an Android app and I would like to display a progress bar while the ktor server is receiving the file. my code looks like this:
Copy code
// 1
call.receiveMultipart().forEachPart { part ->
    // 2
    when (part) {
        is PartData.FileItem -> {
            val input = part.provider()
            // Read from input by chunks
        }
        else -> {}
    }
}
I would like to listen to the progress between (1) and (2). Right now (1) is called, then the file is fully uploaded to the server, and then (2) is called.
a
@FunkyMuse your link shows how to do it on the client side. I am interested about the progress on the server side
f
oh, sorry, didn’t notice it, you can read the bytes and as you’re reading them you update the progress
a
how do i do that?
in the code snippet above, (2) is called when the file is already done sending. I could not find any other ‘hook’ i can write code in
😢 1
I had a look at (custom) Plugins and Logging. I can’t find a way to get updates on bytes received 😞
@e5l do you happen to know? we had a brief chat about this with @seb about it and he mentioned you might know.
e
Hey, thanks for the report! @Aleksei Tirman [JB] is working on the reproducer right now, so we can get more details
a
Cheers. To reproduce on my end, I am sending a 1gb file (or big enough file so it takes a few seconds to upload). you’ll notice that you’ll get (2) after the file is fully uploaded to ktor. EDIT: I am using OkHttp to send the file via a post within a MultipartBody.
s
Hi @e5l 👋
👋 1
a
@Aleksei Tirman [JB] saw the update on the issue. so it is not meant to have any delay before reading from the provider? if that’s the case that would be 100% perfect for my case
a
I see it as a problem that should be addressed.