現在Playframework 2.5.3を使ってアプリケーション開発をしているのですが、その際に「PlayでFilenameを読みこみ -> ユーザへ出力」と言った感じの処理をしようとし、コンパイルエラーが出ています。
これは、どうすればよろしいのでしょうか?
環境
Ubuntu 16.04 LTS
Scala 2.9.2
Playframework 2.5.3
コード
scala
1package controllers 2 3import javax.inject._ 4import play.api._ 5import play.api.mvc._ 6 7import java.net.URLDecoder 8import java.net.URLEncoder 9import java.nio.charset.StandardCharsets 10 11import play.api.mvc.Result 12import play.mvc.Http.Request 13import com.fasterxml.jackson.databind.JsonNode 14import com.fasterxml.jackson.databind.node._ 15import java.io._ 16import scala.sys.process._ 17import play.api.libs.iteratee.Enumerator 18 19@Singleton 20class main @Inject() extends Controller { 21 22 def download(id: Option[String]) = Action{ 23 val file = new File("/datadisk/audio.mp3") 24 val fileContent: Enumerator[Array[Byte]] = Enumerator.fromFile(file) 25 26 Result( 27 header = ResponseHeader(200, Map(CONTENT_LENGTH -> file.length.toString)), 28 body = fileContent 29 ) 30 } 31}
エラー内容
type mismatch; found : play.api.libs.iteratee.Enumerator[Array[Byte]] required: play.api.http.HttpEntity
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。