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)) => case Some(file) if(mimeTypeChcker(file.name)) =>
defining(FileUtil.generateFileId){ fileId => defining(FileUtil.generateFileId){ fileId =>
f(file, fileId) f(file, fileId)
contentType = "text/plain"
Ok(fileId) Ok(fileId)
} }
case _ => BadRequest() case _ => BadRequest()

View File

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