Class FileUpload
java.lang.Object
jodd.http.upload.FileUpload
- Direct Known Subclasses:
AdaptiveFileUpload, DiskFileUpload, MemoryFileUpload
Encapsulates base for uploaded file. Its instance may be
either valid, when it represent an uploaded file, or invalid
when uploaded file doesn't exist or there was a problem with it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected final FileUploadHeaderprotected final MultipartRequestInputStreamprotected final intprotected intprotected boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFileUpload(MultipartRequestInputStream input, int maxFileSize) -
Method Summary
Modifier and TypeMethodDescriptionabstract byte[]Returns all bytes of uploaded file.abstract InputStreamReturns input stream of uploaded file.ReturnsFileUploadHeaderof uploaded file.intReturns max file size or-1if there is no max file size.intgetSize()Returns the file upload size or-1if file was not uploaded.booleanReturnstrueif file is too big.abstract booleanReturnstrueif uploaded file content is stored in memory.booleanReturnstrueif file was uploaded.booleanisValid()Returnstrueif upload process went correctly.protected abstract voidProcess request input stream.toString()Returns basic information about the uploaded file.
-
Field Details
-
input
-
maxFileSize
protected final int maxFileSize -
header
-
valid
protected boolean valid -
size
protected int size -
fileTooBig
protected boolean fileTooBig
-
-
Constructor Details
-
FileUpload
-
-
Method Details
-
getHeader
ReturnsFileUploadHeaderof uploaded file. -
getFileContent
Returns all bytes of uploaded file.- Throws:
IOException
-
getFileInputStream
Returns input stream of uploaded file.- Throws:
IOException
-
getSize
public int getSize()Returns the file upload size or-1if file was not uploaded. -
isUploaded
public boolean isUploaded()Returnstrueif file was uploaded. -
isValid
public boolean isValid()Returnstrueif upload process went correctly. This still does not mean that file is uploaded, e.g. when file was not specified on the form. -
getMaxFileSize
public int getMaxFileSize()Returns max file size or-1if there is no max file size. -
isFileTooBig
public boolean isFileTooBig()Returnstrueif file is too big. File will be marked as invalid. -
isInMemory
public abstract boolean isInMemory()Returnstrueif uploaded file content is stored in memory. -
processStream
Process 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.- Throws:
IOException- See Also:
-
toString
-