I'm using akka http to implement a REST service and that works fine except
for one case. The HTTP message parser has a limit on the message size. This
means that I cannot upload "large" data using a simple POST message,
extract the "entity.dataBytes" and write that to a file. Is there a way how
I can get access to a "raw" stream such that it also works with arbitrary
file sizes? The simplistic solution below doesn't work for large data (due
to the message size limitation):
val routes = {
pathSingleSlash {
(post & extractRequest) {
request => {
val source = request.entity.dataBytes
val outFile = new File("/tmp/outfile.dat")
val sink = SynchronousFileSink.create(outFile)
val repl = source.runWith(sink).map(x => s"Finished uploading
${x} bytes!")
onSuccess(repl) { repl =>
complete(HttpResponse(status = StatusCodes.OK, entity = repl))
}
}
}
}
}
Http().bindAndHandle(routes, config.getString("http.interface"),
config.getInt("http.port"))
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.