0

Could be a silly question, but...

I have a Spring-based WAR application that runs 80% of the installations on Tomcat and the rest 20% on WebSphere.

I need to simply get the path of the folder where Spring's MultipartFilter (using Commons multipart resolver) stores files being uploaded. I have never set it manually, and it actually belongs to the Catalina work directory as I found out in my Tomcat installations.

For the moment, I just need to get that path. I have control of my application so no one is going to change it without notice.

I would like to know if there is a server-agnostic way to know where my Spring-based application is going to store Multipart files.

E.g. from this question I can see I can use catalina.base, but in Tomcat... not in JBoss or WebSphere. It could cost me a couple of if/else statements...

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305

1 Answers1

0

Spring tries to do it already when no default value is set

WebUtils.getTempDir(servletContext)

Which simply does:

return ((File)servletContext.getAttribute("javax.servlet.context.tempdir"));

So simply if no one overrides that location in the filter properties (and that is my case) I can rely on the default.

More in general, one may have to inspect the instance of DiskItemFileFactory to get the path to the repository

usr-local-ΕΨΗΕΛΩΝ
  • 26,101
  • 30
  • 154
  • 305