Class AdaptiveFileUpload
java.lang.Object
jodd.http.upload.FileUpload
jodd.http.upload.impl.AdaptiveFileUpload
Smart
FileUpload implementation that defer the action of what to do with uploaded file
for later. Internally, it stores uploaded file either in memory if it is small, or, in all
other cases, it stores them in TEMP folder.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanprotected final booleanprotected byte[]protected final String[]protected final intprotected Fileprotected static final Stringprotected final FileFields inherited from class FileUpload
fileTooBig, header, input, maxFileSize, size, valid -
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveFileUpload(MultipartRequestInputStream input, int memoryThreshold, File uploadPath, int maxFileSize, boolean breakOnError, String[] extensions, boolean allowed) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanDetermines if upload is allowed.voiddelete()Deletes file uploaded item from disk or memory.byte[]Returns the content of file upload item.String[]Returns input stream of uploaded file.intbooleanbooleanbooleanReturnstrueif file upload resides in memory.protected booleanprotected voidProcess request input stream.Writes file upload item to destination folder or to destination file.Writes file uploaded item.Methods inherited from class FileUpload
getHeader, getMaxFileSize, getSize, isFileTooBig, isUploaded, isValid, toString
-
Field Details
-
TMP_FILE_SUFFIX
- See Also:
-
memoryThreshold
protected final int memoryThreshold -
uploadPath
-
breakOnError
protected final boolean breakOnError -
fileExtensions
-
allowFileExtensions
protected final boolean allowFileExtensions -
tempFile
-
data
protected byte[] data
-
-
Constructor Details
-
AdaptiveFileUpload
AdaptiveFileUpload(MultipartRequestInputStream input, int memoryThreshold, File uploadPath, int maxFileSize, boolean breakOnError, String[] extensions, boolean allowed)
-
-
Method Details
-
getMemoryThreshold
public int getMemoryThreshold() -
getUploadPath
-
isBreakOnError
public boolean isBreakOnError() -
getFileExtensions
-
isAllowFileExtensions
public boolean isAllowFileExtensions() -
isInMemory
public boolean isInMemory()Returnstrueif file upload resides in memory.- Specified by:
isInMemoryin classFileUpload
-
matchFileExtension
- Throws:
IOException
-
checkUpload
Determines if upload is allowed.- Throws:
IOException
-
processStream
Description copied from class:FileUploadProcess request input stream. Note that file size is unknown at this point. Therefore, the implementation should set thesizeattribute after successful processing. This method also must set thevalidattribute.- Specified by:
processStreamin classFileUpload- Throws:
IOException- See Also:
-
delete
public void delete()Deletes file uploaded item from disk or memory. -
write
Writes file uploaded item.- Throws:
IOException
-
write
Writes file upload item to destination folder or to destination file. Returns the destination file.- Throws:
IOException
-
getFileContent
Returns the content of file upload item.- Specified by:
getFileContentin classFileUpload- Throws:
IOException
-
getFileInputStream
Description copied from class:FileUploadReturns input stream of uploaded file.- Specified by:
getFileInputStreamin classFileUpload- Throws:
IOException
-