object play.http.HttpEntity.Streamed is not a value
使用Scala和Play 2.5.10(根据plugin.sbt)我有以下代码:
1 2 3 4 5 6
| import akka. stream. scaladsl. Source
import play. api. libs. streams. Streams
import play. http. _
val source = Source. fromPublisher(Streams. enumeratorToPublisher(enumerator ))
Ok. sendEntity(HttpEntity. Streamed(source, None, Some ("application/zip"))) |
那里的导入大部分来自测试,因为无论我尝试什么,我都无法获得接受HttpEntity.Streamed的框架。使用此设置,错误就是标题所说的。或从控制台获取:
在这里查看文档,我无法真正弄清为什么它不起作用:https://www.playframework.com/documentation/2.5.10/api/java/play/http/HttpEntity.Streamed。 html
这也是官方示例所使用的:https://www.playframework.com/documentation/2.5.x/ScalaStream
至少有人在开始寻找目标时有一些指示吗?我以前从未使用过Scala或Play,因此欢迎您提供任何提示。
您应该导入此
1 2 3 4 5
| import play. api. http. HttpEntity
import play. api. libs. streams. Streams
val entity : HttpEntity = HttpEntity. Streamed(fileContent, None, None )
Result (ResponseHeader (200), entity ). as(MemeFoRTheFile ) |
这意味着HttpEntity.Streamed不是值,因此您应该将其package在带有ResponseHeader及其扩展名的Result()中。
- 似乎只是缺少了" import play.api.http.HttpEntity"。不过,当我查看文档时,不确定为什么.api在那里。
-
play.api.xxx用于scala api。 play.xxx(主要)用于java api。