akka-http文件上传不上传整个文件?

时间:2015-12-04 03:33:35

标签: akka akka-http

我有以下服务器

object FileUploadServer {
  implicit val system = ActorSystem("fileUploadServer")
  implicit val materializer = ActorMaterializer()
  implicit val ec = system.dispatcher


  val route =
    path("upload") {
      post {
        extractRequest { request =>
          println(request)
          val file = File.createTempFile("debug",".zip")
          val futureDone: Future[Long] = request.entity.dataBytes.runWith(Sink.file(file))

          onComplete(futureDone) { result =>
            complete(s"path:${file.getAbsolutePath}, size:${result.get}")
          }
        }
      }
    }

  def main(args: Array[String]) {
    val serverFuture: Future[ServerBinding] = Http().bindAndHandle(route, "localhost", 8080)

    println("FileUpload server is running at http://localhost:8080\nPress RETURN to stop ...")
    readLine()

    serverFuture
      .flatMap(_.unbind())
      .onComplete(_ => system.terminate())
  }
}

我在application.conf

中有以下属性
akka.http.parsing.max-content-length = 1000m

但是当我尝试上传300MB个zip文件时,它只会在159MB

时返回
$ time curl -X POST -H 'Content-Type: application/octet-stream' -d @bluecoat_proxy_big.zip http://localhost:8080/upload 
path:/var/folders/_2/q9xz_8ks73d0h6hq80c7439s8_x7qx/T/debug3960545903381659311.zip, size:155858257
real    0m1.426s
user    0m0.375s
sys 0m0.324s

我错过了什么?

0 个答案:

没有答案