I'm very new to play framework, functional programming and Iteratee I/O, so maybe my question is very out of topic or even stupid.
I would like to upload big text files as stream to a third party and in the same time extract Meta Data about this file (based on its content, to simplify said it's a csv file).
I've already written two working body parsers: Iteratee[Array[Byte], B]
that contains the writing logic and an Iteratee[Array[Byte], MetaData]
that contains the MetaData extracting logic. Could you please tell me how to combine these two parsers to handle Writing and extracting content in the same time
If you have two iteratees, it1
and it1
, say, you can created a "zipped" iteratee from them (zippedIt
in the code below) that will send whatever input it receives to both iteratees, it1
and it2
. See the Play Iteratee documentation of zip
.
Here's an example:
import play.api.libs.iteratee.{Enumerator, Iteratee, Enumeratee}
val e = Enumerator("1", "2", "3")
val it1 = Iteratee.foreach[String](v => println("1: " + v))
val it2 = Iteratee.foreach[String](v => println("2: " + v))
val zippedIt = Enumeratee.zip(it1, it2)
e(zippedIt)
The console output of this small snippet is:
1: 1
2: 1
1: 2
2: 2
1: 3
2: 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With