Kotlin 如何使用HttpRequest.sendStream()获取上载文件的状态?

Kotlin 如何使用HttpRequest.sendStream()获取上载文件的状态?,kotlin,vert.x,Kotlin,Vert.x,我编写了一个函数,将其文件上传到云服务。它工作得很好,但我不知道如何检查上传文件的进度 suspend fun uploadFile(path: Path) { ... val asyncFile: AsyncFile = awaitResult { fs.open(path.toString(), OpenOptions(), it) } val methodType: HttpMethod = when (link.method.toLowerCase()) {

我编写了一个函数,将其文件上传到云服务。它工作得很好,但我不知道如何检查上传文件的进度

suspend fun uploadFile(path: Path) {
    ...
    val asyncFile: AsyncFile = awaitResult { fs.open(path.toString(), OpenOptions(), it) }
    val methodType: HttpMethod = when (link.method.toLowerCase()) {
        "put" -> HttpMethod.PUT
        "post" -> HttpMethod.POST
        else -> throw UnsupportedOperationException("Method is not supported")
    }
    val request: HttpRequest<Buffer> = webClient.requestAbs(methodType, link.href)
    val response: HttpResponse<Buffer> = awaitResult { request.sendStream(asyncFile, it) }
}
您可以使用委托包装AsyncFile提供的ReadStream接口,并在处理程序方法中使用AsyncFile发出的字节数更新计数器,这将告诉您已发送了多少文件