I am working on akka-http (akka-http-experimental_2.11 - 0.4) for a pilot project. and I have not worked on Spray before.
I would like to stream mp4 video streaming (size may vary) in the browser. But I do not know how to create HttpEntity for HttpResponse (HttpEntity.Chunked?). I tried something dirty like this, which is not the right way, but it works in Firefox for only one request.
def output = Source.fromFile("C:\\Users\\karthik\\Downloads\\big_buck_bunny.mp4")(scala.io.Codec.ISO8859) lazy val video = HttpResponse(entity = HttpEntity.Chunked(MediaTypes.`video/mp4`, Flow(output.map(_.toByte).map(a => ChunkStreamPart(ByteString(a)))).toProducer(materializer)))
When I open the same URL in another tab or browser, the server cannot process this request. Since this is an experimental project, there is not enough documentation for large file streaming.
I got a sample source code https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/test/scala/akka/http/TestServer.scala
I need to know how to create a Producer for HttpEntity.Chunked. If someone can explain in plain language, this will be useful for understanding the API.
Thanks.
(PS: Someone, please create an Akka-Http tag in the stack overflow)
source share