使用流转换器时无法完成。 PlayFramework中的asoutputstream.mapMaterializedValue

时间:2017-11-10 16:46:06

标签: scala playframework outputstream akka-stream

当我跑步时:

def zip() = Action {
  val zipSource: Source[ByteString, _] =
    StreamConverters
      .asOutputStream()
      .mapMaterializedValue(os => Future {
         Thread.sleep(1)
         println("*********** Start")
         os.write("happy".getBytes("UTF8"))
         println("*********** Sent")
         os.close()
         println("*********** OS closed")
      })

  Status(200).sendEntity(HttpEntity.Streamed(zipSource, None, Some("application/zip")))
}

我收到了打印声明:

[info] play.api.Play - Application started (Dev)
*********** Start
*********** Sent
*********** OS closed

但是,下载过程保持在“正在启动”状态,并且永远不会向前发展。我必须取消这个过程。有谁知道为什么?

0 个答案:

没有答案