[
https://issues.apache.org/jira/browse/GEARPUMP-205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15467355#comment-15467355
]
ASF GitHub Bot commented on GEARPUMP-205:
-----------------------------------------
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
> remove hdfs dependency from command gear's classpath
> ----------------------------------------------------
>
> Key: GEARPUMP-205
> URL: https://issues.apache.org/jira/browse/GEARPUMP-205
> Project: Apache Gearpump
> Issue Type: Improvement
> Components: core
> Affects Versions: 0.8.2
> Reporter: Huafeng Wang
> Assignee: Huafeng Wang
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)