val inputStream = new PipedInputStream()
val outputStream = new PipedOutputStream(ios)
Future{ /** Write to outputStream */ }
Ok.chunked(StreamConverters.fromInputStream(() => inputStream))
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/b53aa337-96f9-4876-9071-9be6d3beea7c%40googlegroups.com.
Dragiša Krsmanović | Platform Engineer | Ticketfly
Actually I guess the following could work, too:
val source = StreamConverters.asOutputStream().mapMaterializedValue(os => Future{report.write(os)})
Ok.chunked(source)
Btw. it's best to close the outputStream after write, so that the source will be closed and the upstream handler knows that data writing is finished.
Actually I guess that works, too:val (outputStream, publisher) = StreamConverters.asOutputStream().toMat(Sink.asPublisher(false))(Keep.both).run()
Future { /* write to outputstream */ }
Ok.chunked(Source.fromPublisher(publisher))
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/255b6233-6368-4106-82ca-63b9294ce763%40googlegroups.com.