Package jodd.http.upload
Class FileUpload
- java.lang.Object
-
- jodd.http.upload.FileUpload
-
- Direct Known Subclasses:
AdaptiveFileUpload,DiskFileUpload,MemoryFileUpload
public abstract class FileUpload extends java.lang.ObjectEncapsulates 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
Fields Modifier and Type Field Description protected booleanfileTooBigprotected FileUploadHeaderheaderprotected MultipartRequestInputStreaminputprotected intmaxFileSizeprotected intsizeprotected booleanvalid
-
Constructor Summary
Constructors Modifier Constructor Description protectedFileUpload(MultipartRequestInputStream input, int maxFileSize)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract byte[]getFileContent()Returns all bytes of uploaded file.abstract java.io.InputStreamgetFileInputStream()Returns input stream of uploaded file.FileUploadHeadergetHeader()ReturnsFileUploadHeaderof uploaded file.intgetMaxFileSize()Returns max file size or-1if there is no max file size.intgetSize()Returns the file upload size or-1if file was not uploaded.booleanisFileTooBig()Returnstrueif file is too big.abstract booleanisInMemory()Returnstrueif uploaded file content is stored in memory.booleanisUploaded()Returnstrueif file was uploaded.booleanisValid()Returnstrueif upload process went correctly.protected abstract voidprocessStream()Process request input stream.java.lang.StringtoString()Returns basic information about the uploaded file.
-
-
-
Field Detail
-
input
protected final MultipartRequestInputStream input
-
maxFileSize
protected final int maxFileSize
-
header
protected final FileUploadHeader header
-
valid
protected boolean valid
-
size
protected int size
-
fileTooBig
protected boolean fileTooBig
-
-
Constructor Detail
-
FileUpload
protected FileUpload(MultipartRequestInputStream input, int maxFileSize)
-
-
Method Detail
-
getHeader
public FileUploadHeader getHeader()
ReturnsFileUploadHeaderof uploaded file.
-
getFileContent
public abstract byte[] getFileContent() throws java.io.IOExceptionReturns all bytes of uploaded file.- Throws:
java.io.IOException
-
getFileInputStream
public abstract java.io.InputStream getFileInputStream() throws java.io.IOExceptionReturns input stream of uploaded file.- Throws:
java.io.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
protected abstract void processStream() throws java.io.IOExceptionProcess 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:
java.io.IOException- See Also:
MultipartRequestInputStream
-
toString
public java.lang.String toString()
Returns basic information about the uploaded file.- Overrides:
toStringin classjava.lang.Object
-
-