Configure Tomcat to create upload targets

Previously, if the directory to which Tomcat would write a file upload did not exist
the upload attempt would fail and a 500 response would be returned to the client.
This could happen when, for example, Tomcat is using a temporary directory for file
uploads and tmpwatch has deleted the directory.

This commit configures Tomcat so that, during multipart request parsing, it will
automatically create the directory to which the parts will be written if it does not
already exist.

Closes gh-9616
This commit is contained in:
Andy Wilkinson
2019-03-28 16:52:51 +00:00
parent f8bd066970
commit 70eee612ff
3 changed files with 65 additions and 7 deletions

View File

@@ -2306,13 +2306,6 @@ Spring Boot includes support for embedded Tomcat, Jetty, and Undertow servers. M
developers will simply use the appropriate '`Starter`' to obtain a fully configured
instance. By default the embedded server will listen for HTTP requests on port `8080`.
WARNING: If you choose to use Tomcat on CentOS be aware that, by default, a temporary
directory is used to store compiled JSPs, file uploads etc. This directory may be
deleted by `tmpwatch` while your application is running leading to failures. To avoid
this, you may want to customize your `tmpwatch` configuration so that `tomcat.*`
directories are not deleted, or configure `server.tomcat.basedir` so that embedded Tomcat
uses a different location.
[[boot-features-embedded-container-servlets-filters-listeners]]