skinny.micro.multipart.MultipartConfig.scala Maven / Gradle / Ivy
The newest version!
package skinny.micro.multipart
import javax.servlet.{ MultipartConfigElement, ServletContext }
import skinny.micro.context.MountConfig
/**
* Multipart config.
*/
case class MultipartConfig(
location: Option[String] = None,
maxFileSize: Option[Long] = None,
maxRequestSize: Option[Long] = None,
fileSizeThreshold: Option[Int] = None) extends MountConfig {
def toMultipartConfigElement: MultipartConfigElement = {
new MultipartConfigElement(
location.getOrElse(""),
maxFileSize.getOrElse(-1),
maxRequestSize.getOrElse(-1),
fileSizeThreshold.getOrElse(0))
}
def apply(ctx: ServletContext): Unit = {
ctx.setAttribute(HasMultipartConfig.MultipartConfigKey, this)
}
}