Github user manuzhang commented on a diff in the pull request: https://github.com/apache/incubator-gearpump/pull/81#discussion_r77628699 --- Diff: core/src/main/scala/org/apache/gearpump/jarstore/FileDirective.scala --- @@ -96,24 +105,47 @@ object FileDirective { } // Downloads file from server - def downloadFile(file: File): Route = { + def downloadFileFrom(jarStore: JarStore, filePath: String): Route = { val responseEntity = HttpEntity( MediaTypes.`application/octet-stream`, - file.length, - FileIO.fromFile(file, CHUNK_SIZE)) + StreamConverters.fromInputStream( + () => jarStore.getFile(filePath), CHUNK_SIZE + )) complete(responseEntity) } - private def uploadFileImpl(rootDirectory: File)(implicit mat: Materializer, ec: ExecutionContext) + private def uploadFileImpl(jarStore: JarStore) + (implicit mat: Materializer, ec: ExecutionContext): Directive1[Future[Map[Name, FilePath]]] = { + Directive[Tuple1[Future[Map[Name, FilePath]]]] { inner => + entity(as[Multipart.FormData]) { (formdata: Multipart.FormData) => + val fileNameMap = formdata.parts.mapAsync(1) { p => + if (p.filename.isDefined) { + val path = Instant.now() + p.filename.get + val sink = StreamConverters.fromOutputStream(() => jarStore.createFile(path), true) + val written = p.entity.dataBytes.runWith(sink) + written.map(written => --- End diff -- better use a different local name
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---