https://kotlinlang.org logo
#vertx
Title
# vertx
j

janvladimirmostert

10/14/2020, 8:29 AM
how does one implement a streaming upload handler in VertX? if i'm uploading a 10GB file, i don't want it to sit inside an in-memory buffer I've started messing around with custom handlers, but not sure how to access the stream
Copy code
class LulaUploadHandler : Handler<RoutingContext> {
			override fun handle(ctx: RoutingContext) {
				try {
					val request = ctx.request()
					request.streamPriorityHandler {
						<http://log.info|log.info>("blah")
					}

					<http://log.info|log.info>(request.bytesRead().toString())



				} catch (e: Exception) {
					log.error(e.message ?: "", e)
				}
				ctx.response().end("completed")
			}
		}
		<http://router.post|router.post>("/leupload").handler(LulaUploadHandler())
this seems to work
Copy code
class LulaUploadHandler : Handler<RoutingContext> {
			override fun handle(ctx: RoutingContext) {
				try {
					val request = ctx.request()
					request.pipeTo(LulaWriterStream())
then inside the custom WriterStream implementation i get access to the bytes
a

asad.awadia

10/14/2020, 2:16 PM
yeah - use a pipe and pipe it to a file or something
70 Views