Fix file uploading issue

This commit is contained in:
Naoki Takezoe
2017-12-06 03:53:43 +09:00
parent 557ed827d0
commit 27ab21c9a7
2 changed files with 21 additions and 16 deletions

View File

@@ -116,6 +116,7 @@ class FileUploadController extends ScalatraServlet with FileUploadSupport with R
case Some(file) if(mimeTypeChcker(file.name)) =>
defining(FileUtil.generateFileId){ fileId =>
f(file, fileId)
contentType = "text/plain"
Ok(fileId)
}
case _ => BadRequest()

View File

@@ -36,18 +36,22 @@ class CompositeScalatraFilter extends Filter {
requestPath + "/"
}
filters
.filter { case (_, path) =>
val start = path.replaceFirst("/\\*$", "/")
checkPath.startsWith(start)
}
.foreach { case (filter, _) =>
val mockChain = new MockFilterChain()
filter.doFilter(request, response, mockChain)
if(mockChain.continue == false){
return ()
if(!checkPath.startsWith("/upload/") && !checkPath.startsWith("/git/") && !checkPath.startsWith("/git-lfs/") &&
!checkPath.startsWith("/plugin-assets/") && !checkPath.startsWith("/console/")){
filters
.filter { case (_, path) =>
val start = path.replaceFirst("/\\*$", "/")
checkPath.startsWith(start)
}
}
.foreach { case (filter, _) =>
val mockChain = new MockFilterChain()
filter.doFilter(request, response, mockChain)
if(mockChain.continue == false){
return ()
}
}
}
chain.doFilter(request, response)
}
@@ -62,8 +66,8 @@ class MockFilterChain extends FilterChain {
}
}
class FilterChainFilter(chain: FilterChain) extends Filter {
override def init(filterConfig: FilterConfig): Unit = ()
override def destroy(): Unit = ()
override def doFilter(request: ServletRequest, response: ServletResponse, mockChain: FilterChain) = chain.doFilter(request, response)
}
//class FilterChainFilter(chain: FilterChain) extends Filter {
// override def init(filterConfig: FilterConfig): Unit = ()
// override def destroy(): Unit = ()
// override def doFilter(request: ServletRequest, response: ServletResponse, mockChain: FilterChain) = chain.doFilter(request, response)
//}