Skip to content

Instantly share code, notes, and snippets.

@ybonnel
Created November 28, 2018 10:53
Show Gist options
  • Save ybonnel/38fad2a2009b7daa0abd17d77c10ceef to your computer and use it in GitHub Desktop.
Save ybonnel/38fad2a2009b7daa0abd17d77c10ceef to your computer and use it in GitHub Desktop.
Vertx BodyHandler stuck on big file
curl -XPOST -F "file=@BigFile" "http://localhost:8080/"
# Tested with 20Mo file
import io.vertx.core.Vertx
import io.vertx.ext.web.Router
import io.vertx.ext.web.handler.BodyHandler
fun main(args: Array<String>) {
val vertx = Vertx.vertx()
val router = Router.router(vertx)
router.route().handler(
BodyHandler.create()
)
router.route().handler {
val result = it.fileUploads().joinToString("\n") { upload ->
"${upload.name()} : ${upload.size()}"
}
it.response().end(result)
}
vertx
.createHttpServer()
.requestHandler(router::accept)
.listen(8080) { http ->
if (http.succeeded()) {
println("HTTP server started on port 8080")
} else {
http.cause().printStackTrace()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment