Update MultipartProperties' prefix to reflect that it's Servlet-specific

Closes gh-8628
pull/9103/head
Andy Wilkinson 8 years ago
parent 9caf82ce80
commit 525f421441

@ -23,6 +23,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean;
@ -39,7 +41,7 @@ import org.springframework.web.servlet.DispatcherServlet;
* {@link MultipartConfigElement} bean to any {@link Servlet} beans.
* <p>
* The {@link javax.servlet.MultipartConfigElement} is a Servlet API that's used to
* configure how the server handles file uploads. By default
* configure how the server handles file uploads.
*
* @author Greg Turnquist
* @author Josh Long
@ -48,7 +50,8 @@ import org.springframework.web.servlet.DispatcherServlet;
@Configuration
@ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class,
MultipartConfigElement.class })
@ConditionalOnProperty(prefix = "spring.http.multipart", name = "enabled", matchIfMissing = true)
@ConditionalOnProperty(prefix = "spring.servlet.multipart", name = "enabled", matchIfMissing = true)
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(MultipartProperties.class)
public class MultipartAutoConfiguration {

@ -26,15 +26,14 @@ import org.springframework.util.StringUtils;
* Properties to be used in configuring a {@link MultipartConfigElement}.
* <ul>
* <li>{@link #getLocation() location} specifies the directory where files will be stored.
* The default is "". A common value is to use the system's temporary directory, which can
* be obtained.</li>
* The default is "". A common value is to use the system's temporary directory</li>
* <li>{@link #getMaxFileSize() max-file-size} specifies the maximum size permitted for
* uploaded files. The default is 1MB.</li>
* uploaded files. The default is 1MB</li>
* <li>{@link #getMaxRequestSize() max-request-size} specifies the maximum size allowed
* for {@literal multipart/form-data} requests. The default is 10MB</li>
* <li>{@link #getFileSizeThreshold() file-size-threshold} specifies the size threshold
* after which files will be written to disk. Default is 0, which means that the file will
* be written to disk immediately.</li>
* be written to disk immediately</li>
* </ul>
* <p>
* These properties are ultimately passed through {@link MultipartConfigFactory} which
@ -45,11 +44,11 @@ import org.springframework.util.StringUtils;
* @author Toshiaki Maki
* @since 1.1.0
*/
@ConfigurationProperties(prefix = "spring.http.multipart", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "spring.servlet.multipart", ignoreUnknownFields = false)
public class MultipartProperties {
/**
* Enable support of multi-part uploads.
* Enable support of multipart uploads.
*/
private boolean enabled = true;
@ -59,20 +58,20 @@ public class MultipartProperties {
private String location;
/**
* Max file size. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or
* Kilobyte size.
* Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or
* kilobytes respectively.
*/
private String maxFileSize = "1MB";
/**
* Max request size. Values can use the suffixed "MB" or "KB" to indicate a Megabyte
* or Kilobyte size.
* Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or
* kilobytes respectively.
*/
private String maxRequestSize = "10MB";
/**
* Threshold after which files will be written to disk. Values can use the suffixed
* "MB" or "KB" to indicate a Megabyte or Kilobyte size.
* Threshold after which files will be written to disk. Values can use the suffixes
* "MB" or "KB" to indicate megabytes or kilobytes respectively.
*/
private String fileSizeThreshold = "0";

@ -183,7 +183,7 @@ public class MultipartAutoConfigurationTests {
final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.http.multipart.enabled=" + propertyValue);
"spring.servlet.multipart.enabled=" + propertyValue);
this.context.register(WebServerWithNoMultipartTomcat.class,
BaseConfiguration.class);
this.context.refresh();
@ -206,7 +206,7 @@ public class MultipartAutoConfigurationTests {
public void configureResolveLazily() {
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context,
"spring.http.multipart.resolve-lazily=true");
"spring.servlet.multipart.resolve-lazily=true");
this.context.register(WebServerWithNothing.class, BaseConfiguration.class);
this.context.refresh();
StandardServletMultipartResolver multipartResolver = this.context

@ -303,12 +303,12 @@ content into your application; rather pick only the properties that you need.
spring.http.encoding.mapping= # Locale to Encoding mapping.
# MULTIPART ({sc-spring-boot-autoconfigure}/web/servlet/MultipartProperties.{sc-ext}[MultipartProperties])
spring.http.multipart.enabled=true # Enable support of multi-part uploads.
spring.http.multipart.file-size-threshold=0 # Threshold after which files will be written to disk. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.
spring.http.multipart.location= # Intermediate location of uploaded files.
spring.http.multipart.max-file-size=1MB # Max file size. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.
spring.http.multipart.max-request-size=10MB # Max request size. Values can use the suffixed "MB" or "KB" to indicate a Megabyte or Kilobyte size.
spring.http.multipart.resolve-lazily=false # Whether to resolve the multipart request lazily at the time of file or parameter access.
spring.servlet.multipart.enabled=true # Enable support of multipart uploads.
spring.servlet.multipart.file-size-threshold=0 # Threshold after which files will be written to disk. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively.
spring.servlet.multipart.location= # Intermediate location of uploaded files.
spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively.
spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively.
spring.servlet.multipart.resolve-lazily=false # Whether to resolve the multipart request lazily at the time of file or parameter access.
# JACKSON ({sc-spring-boot-autoconfigure}/jackson/JacksonProperties.{sc-ext}[JacksonProperties])
spring.jackson.date-format= # Date format string or a fully-qualified date format class name. For instance `yyyy-MM-dd HH:mm:ss`.

@ -1172,7 +1172,7 @@ file and a maximum of 10MB of file data in a single request. You may override th
values, as well as the location to which intermediate data is stored (e.g., to the `/tmp`
directory) and the threshold past which data is flushed to disk by using the properties
exposed in the `MultipartProperties` class. If you want to specify that files be
unlimited, for example, set the `spring.http.multipart.max-file-size` property to `-1`.
unlimited, for example, set the `spring.servlet.multipart.max-file-size` property to `-1`.
The multipart support is helpful when you want to receive multipart encoded file data as
a `@RequestParam`-annotated parameter of type `MultipartFile` in a Spring MVC controller

Loading…
Cancel
Save