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.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 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.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -39,7 +41,7 @@ import org.springframework.web.servlet.DispatcherServlet;
* {@link MultipartConfigElement} bean to any {@link Servlet} beans. * {@link MultipartConfigElement} bean to any {@link Servlet} beans.
* <p> * <p>
* The {@link javax.servlet.MultipartConfigElement} is a Servlet API that's used to * 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 Greg Turnquist
* @author Josh Long * @author Josh Long
@ -48,7 +50,8 @@ import org.springframework.web.servlet.DispatcherServlet;
@Configuration @Configuration
@ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class, @ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class,
MultipartConfigElement.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) @EnableConfigurationProperties(MultipartProperties.class)
public class MultipartAutoConfiguration { public class MultipartAutoConfiguration {

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

@ -183,7 +183,7 @@ public class MultipartAutoConfigurationTests {
final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) { final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,
"spring.http.multipart.enabled=" + propertyValue); "spring.servlet.multipart.enabled=" + propertyValue);
this.context.register(WebServerWithNoMultipartTomcat.class, this.context.register(WebServerWithNoMultipartTomcat.class,
BaseConfiguration.class); BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
@ -206,7 +206,7 @@ public class MultipartAutoConfigurationTests {
public void configureResolveLazily() { public void configureResolveLazily() {
this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, 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.register(WebServerWithNothing.class, BaseConfiguration.class);
this.context.refresh(); this.context.refresh();
StandardServletMultipartResolver multipartResolver = this.context 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. spring.http.encoding.mapping= # Locale to Encoding mapping.
# MULTIPART ({sc-spring-boot-autoconfigure}/web/servlet/MultipartProperties.{sc-ext}[MultipartProperties]) # MULTIPART ({sc-spring-boot-autoconfigure}/web/servlet/MultipartProperties.{sc-ext}[MultipartProperties])
spring.http.multipart.enabled=true # Enable support of multi-part uploads. spring.servlet.multipart.enabled=true # Enable support of multipart 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.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.http.multipart.location= # Intermediate location of uploaded files. spring.servlet.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.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively.
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.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively.
spring.http.multipart.resolve-lazily=false # Whether to resolve the multipart request lazily at the time of file or parameter access. 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]) # 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`. 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` 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 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 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 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 a `@RequestParam`-annotated parameter of type `MultipartFile` in a Spring MVC controller

Loading…
Cancel
Save