Akka HTTP:使用分段上传时如何从路径访问捕获值(实体(as[Multipart.FormData]))
AkkaHTTP : How to access captured values from the path when using mutlpart upload ( entity(as[ Multipart.FormData]) )
我试图在上传文件时从路径访问捕获的值,但无法了解实现的想法。
示例代码如下:
trait TestRoute extends {
val regEx = """(\w+)""".r
def testRoute: Route = path("testing" / regEx / regEx / regEx){
post {
//How do i Access (captured regex from the path) inside entity
entity(as[Multipart.FormData]) { fileData => {
complete {
"UpLoadDOne"
}
}
}
}
}
http://localhost:9000/testing/A/B/C
感谢您的帮助!
如果你使用喷雾,你需要类似的东西:
import spray.routing.PathMatchers.Segment
trait TestRoute extends {
def testRoute: Route = path("testing" / Segment / Segment / Segment){ case (A, B, C) =>
post {
entity(as[Multipart.FormData]) { fileData =>
complete {
"UpLoadDOne"
}
}
}
}
我试图在上传文件时从路径访问捕获的值,但无法了解实现的想法。
示例代码如下:
trait TestRoute extends {
val regEx = """(\w+)""".r
def testRoute: Route = path("testing" / regEx / regEx / regEx){
post {
//How do i Access (captured regex from the path) inside entity
entity(as[Multipart.FormData]) { fileData => {
complete {
"UpLoadDOne"
}
}
}
}
}
http://localhost:9000/testing/A/B/C
感谢您的帮助!
如果你使用喷雾,你需要类似的东西:
import spray.routing.PathMatchers.Segment
trait TestRoute extends {
def testRoute: Route = path("testing" / Segment / Segment / Segment){ case (A, B, C) =>
post {
entity(as[Multipart.FormData]) { fileData =>
complete {
"UpLoadDOne"
}
}
}
}