Return binary stream as response to playframework request

I have a problem with returning a binary stream from the scope of the game. According to the documentation, the structure should automatically return binary output if it detects that the controller method returns a stream or file. Well, my method returns Stream [Byte], but the structure returns "Stream (100 ,?)", and not a binary stream.

What am I doing wrong? Thanks for the answers, Thomas Herman


change

ok, if someone needs it in the future, it looks like I somehow cracked it. I just build a string from Stream and return it. It seems to work correctly, but I'm sure there is a better solution.

Example:

val builder = new StringBuilder()
builder.clear
stream foreach { x=> builder.append(x.toChar)}
val res = builder.toString

where res is what your controller method should return

+3
source share
1

, , . Stream(100, ?) - Stream, 100, . , stream mkString ("Stream(", ", ", ")").

0

Source: https://habr.com/ru/post/1790212/


All Articles