我试图在http://www.playframework.org/documentation/2.0/ScalaStream上实现类似于"发送大量数据"的第一个例子.
我的不同之处在于我有多个文件要在响应中连接.它看起来像这样:
def index = Action {
val file1 = new java.io.File("/tmp/fileToServe1.pdf")
val fileContent1: Enumerator[Array[Byte]] = Enumerator.fromFile(file1)
val file2 = new java.io.File("/tmp/fileToServe2.pdf")
val fileContent2: Enumerator[Array[Byte]] = Enumerator.fromFile(file2)
SimpleResult(
header = ResponseHeader(200),
body = fileContent1 andThen fileContent2
)
Run Code Online (Sandbox Code Playgroud)
}
发生的事情是只有第一个文件的内容在响应中.
稍微简单如下的一些工作正常:
fileContent1 = Enumerator("blah" getBytes)
fileContent2 = Enumerator("more blah" getBytes)
SimpleResult(
header = ResponseHeader(200),
body = fileContent1 andThen fileContent2
)
Run Code Online (Sandbox Code Playgroud)
我错了什么?