1
play-miniアプリケーションから画像を提供しようとしています。Play-mini:画像を返す方法
object App extends Application {
def route = {
case GET(Path("/image")) => Action { request =>
Ok(Source.fromInputStream(getClass.getResourceAsStream("image.gif")).toArray).as("image/gif")
}
}
}
残念ながら、これはNOEの作業を行います:)あなたはファイルのArray[Byte]
を提供する必要があるので、私は、play20
でWriteable[Array[Byte]]
があらかじめ定義されている
リンクのThx。それは私がそれを把握するのを助けた:) – rompetroll
これは動作します:Ok.stream(Enumerator.fromStream(getClass.getClassLoader.getResourceAsStream( "image.gif")))) – rompetroll