Skip to content

Commit 1d426e8

Browse files
committed
javadoc
1 parent 54cc99d commit 1d426e8

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

src/main/java/io/fusionauth/http/io/MultipartConfiguration.java

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class MultipartConfiguration {
2626
private boolean deleteTemporaryFiles = true;
2727

28-
private MultipartFileUploadPolicy fileUploadPolicy;
28+
private MultipartFileUploadPolicy fileUploadPolicy = MultipartFileUploadPolicy.Reject;
2929

3030
private long maxFileSize = 1024 * 1024; // 1 Megabyte
3131

@@ -117,21 +117,49 @@ public boolean isDeleteTemporaryFiles() {
117117
return deleteTemporaryFiles;
118118
}
119119

120+
/**
121+
* Setting this to <code>true</code> will cause the server to delete all temporary files created while processing a multipart stream after
122+
* the request handler has been invoked.
123+
* <p>
124+
* If you set this to <code>false</code> the request handler will need to manage cleanup of these temporary files.
125+
*
126+
* @param deleteTemporaryFiles controls if temporary files are deleted by the server.
127+
* @return This.
128+
*/
120129
public MultipartConfiguration withDeleteTemporaryFiles(boolean deleteTemporaryFiles) {
121130
this.deleteTemporaryFiles = deleteTemporaryFiles;
122131
return this;
123132
}
124133

134+
/**
135+
* This is the file upload policy for the HTTP server.
136+
*
137+
* @param fileUploadPolicy the file upload policy. Cannot be null.
138+
* @return This.
139+
*/
125140
public MultipartConfiguration withFileUploadPolicy(MultipartFileUploadPolicy fileUploadPolicy) {
141+
Objects.requireNonNull(fileUploadPolicy, "You cannot set the fileUploadPolicy to null");
126142
this.fileUploadPolicy = fileUploadPolicy;
127143
return this;
128144
}
129145

146+
/**
147+
* This is the maximum size for each file found within a multipart stream which may contain one to many files.
148+
*
149+
* @param maxFileSize the maximum file size in bytes
150+
* @return This.
151+
*/
130152
public MultipartConfiguration withMaxFileSize(long maxFileSize) {
131153
this.maxFileSize = maxFileSize;
132154
return this;
133155
}
134156

157+
/**
158+
* This is the maximum size of the request payload in bytes when reading a multipart stream.
159+
*
160+
* @param maxRequestSize the maximum request size in bytes
161+
* @return This.
162+
*/
135163
public MultipartConfiguration withMaxRequestSize(long maxRequestSize) {
136164
if (maxRequestSize < maxFileSize) {
137165
// In practice the maxRequestSize should be more than just one byte larger than maxFileSize, but I am not going to require any specific amount.
@@ -142,21 +170,56 @@ public MultipartConfiguration withMaxRequestSize(long maxRequestSize) {
142170
return this;
143171
}
144172

173+
/**
174+
* @param multipartBufferSize the size of the buffer used to parse a multipart stream.
175+
* @return This.
176+
*/
145177
public MultipartConfiguration withMultipartBufferSize(int multipartBufferSize) {
178+
if (multipartBufferSize <= 0) {
179+
throw new IllegalArgumentException("The multipart buffer size must be greater than 0");
180+
}
181+
146182
this.multipartBufferSize = multipartBufferSize;
147183
return this;
148184
}
149185

186+
/**
187+
* A temporary file location used for creating temporary files.
188+
* <p>
189+
* The specific behavior of creating temporary files will be dependant upon the {@link MultipartFileManager} implementation.
190+
*
191+
* @param temporaryFileLocation the temporary file location. Cannot be <code>null</code>.
192+
* @return This.
193+
*/
150194
public MultipartConfiguration withTemporaryFileLocation(String temporaryFileLocation) {
195+
Objects.requireNonNull(temporaryFileLocation, "You cannot set the temporaryFileLocation to null");
151196
this.temporaryFileLocation = temporaryFileLocation;
152197
return this;
153198
}
154199

200+
/**
201+
* An optional filename prefix used for naming temporary files.
202+
* <p>
203+
* This parameter may be set to <code>null</code>. When set to <code>null</code> a system default such as '.tmp' may be used when naming a
204+
* temporary file depending upon the {@link MultipartFileManager} implementation.
205+
*
206+
* @param temporaryFilenamePrefix an optional filename prefix to be used when creating temporary files.
207+
* @return This.
208+
*/
155209
public MultipartConfiguration withTemporaryFilenamePrefix(String temporaryFilenamePrefix) {
156210
this.temporaryFilenamePrefix = temporaryFilenamePrefix;
157211
return this;
158212
}
159213

214+
/**
215+
* An optional filename suffix used for naming temporary files.
216+
* <p>
217+
* This parameter may be set to <code>null</code>. The specific file naming with or without this optional suffix may be dependant upon the
218+
* {@link MultipartFileManager} implementation. file depending upon the {@link MultipartFileManager} implementation.
219+
*
220+
* @param temporaryFilenameSuffix an optional filename suffix to be used when creating temporary files.
221+
* @return This.
222+
*/
160223
public MultipartConfiguration withTemporaryFilenameSuffix(String temporaryFilenameSuffix) {
161224
this.temporaryFilenameSuffix = temporaryFilenameSuffix;
162225
return this;

0 commit comments

Comments
 (0)