Scala Play:从播放mvc api请求中获取原始数据?

时间:2016-11-11 18:53:23

标签: scala playframework playframework-2.0

我从相机Feed收到一个HTTP请求,每隔10秒左右就会向我的PlayFramework应用程序发送大约4MB的原始数据。有没有什么好方法可以从请求中捕获原始数据并将其保存到磁盘?

def uploadVideoChunk = Action(parse.raw) { request =>
    println(s"Got the request ${request.body.size}")

    val chunkOption = for {
      content = request.body
    } yield {
      VideoChunk(content)
    }

    chunkOption foreach { chunk =>
      val bytes = chunk.content.toString().getBytes
      Files.write(Paths.get("/tmp/video/", "ID-1", chunk.filename), ***???*** )
      println(s"wrote $chunk")
    }

    Ok("some response")
}

0 个答案:

没有答案