Write an OutputStream directly to Response

29 views
Skip to first unread message

Christian Schmitt

unread,
Jul 31, 2015, 4:30:35 AM7/31/15
to play-framework
Hello, I tried many things yet, but I didn't succed. Currently I have a OutputStream and want it to write to the response (it's a pdf, generated via Jasperreports which gives either a Array[Byte] or needs an OutputStream) however while using PipedOutputStream it blocks and deadlocks, I tried to use akka or Enumerator.fromStream, but no success.

Is there a good way to do that, without too much buffering?
Message has been deleted

Christian Schmitt

unread,
Jul 31, 2015, 4:40:43 AM7/31/15
to play-framework, c.sc...@briefdomain.de
Currently if I use Enumerator.outputStream it looks like it will never finish, but after stopping the request the data is downloaded correctly, so it looks like that:

val enumerator = Enumerator.outputStream { os =>
PDFGenerator.x(a, json, os)
}

val headers = Map((CONTENT_TYPE, "application/pdf"), (CONTENT_DISPOSITION, "inline; filename=" + filename + ".pdf"))
Result(
header = ResponseHeader(200, headers),
body = enumerator
)

won't work for me, somehow the PDFGenerator will still call os.close(), but it still won't stop at the eof
Reply all
Reply to author
Forward
0 new messages