Receiving text files

Report a typo

You want to accept files on your server and output their text content to the user. What code should you put instead of the three dots in the handler code?

routing {
    post("/page") {

        ...

    }
}
Reorder lines using drag or arrows. Adjust indentation with left buttons
                }
              
                val parts = call.receiveMultipart().readAllParts()
              
                val fileText = part.streamProvider().readBytes().toString(Charsets.UTF_8)
              
                }
              
                call.respondText(fileText)
              
                for (part in parts) {
              
                if (part is PartData.FileItem) {
              
___

Create a free account to access the full topic