Skip to content

Commit 23124d1

Browse files
committed
CommonsMultipartResolver allows for specifying max upload size per file
Issue: SPR-13200
1 parent f0c6bff commit 23124d1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

spring-web/src/main/java/org/springframework/web/multipart/commons/CommonsFileUploadSupport.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public FileUpload getFileUpload() {
100100
}
101101

102102
/**
103-
* Set the maximum allowed size (in bytes) before uploads are refused.
103+
* Set the maximum allowed size (in bytes) before an upload gets rejected.
104104
* -1 indicates no limit (the default).
105105
* @param maxUploadSize the maximum upload size allowed
106106
* @see org.apache.commons.fileupload.FileUploadBase#setSizeMax
@@ -109,6 +109,17 @@ public void setMaxUploadSize(long maxUploadSize) {
109109
this.fileUpload.setSizeMax(maxUploadSize);
110110
}
111111

112+
/**
113+
* Set the maximum allowed size (in bytes) for each individual file before
114+
* an upload gets rejected. -1 indicates no limit (the default).
115+
* @param maxUploadSizePerFile the maximum upload size per file
116+
* @since 4.2
117+
* @see org.apache.commons.fileupload.FileUploadBase#setFileSizeMax
118+
*/
119+
public void setMaxUploadSizePerFile(long maxUploadSizePerFile) {
120+
this.fileUpload.setFileSizeMax(maxUploadSizePerFile);
121+
}
122+
112123
/**
113124
* Set the maximum allowed size (in bytes) before uploads are written to disk.
114125
* Uploaded files will still be received past this amount, but they will not be

0 commit comments

Comments
 (0)