Class FileUpload

java.lang.Object
jodd.http.upload.FileUpload
Direct Known Subclasses:
AdaptiveFileUpload, DiskFileUpload, MemoryFileUpload

public abstract class FileUpload extends Object
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 Details

    • input

      protected final MultipartRequestInputStream input
    • maxFileSize

      protected final int maxFileSize
    • valid

      protected boolean valid
    • size

      protected int size
    • fileTooBig

      protected boolean fileTooBig
  • Constructor Details

  • Method Details

    • getHeader

      public FileUploadHeader getHeader()
      Returns FileUploadHeader of uploaded file.
    • getFileContent

      public abstract byte[] getFileContent() throws IOException
      Returns all bytes of uploaded file.
      Throws:
      IOException
    • getFileInputStream

      public abstract InputStream getFileInputStream() throws IOException
      Returns input stream of uploaded file.
      Throws:
      IOException
    • getSize

      public int getSize()
      Returns the file upload size or -1 if file was not uploaded.
    • isUploaded

      public boolean isUploaded()
      Returns true if file was uploaded.
    • isValid

      public boolean isValid()
      Returns true if 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 -1 if there is no max file size.
    • isFileTooBig

      public boolean isFileTooBig()
      Returns true if file is too big. File will be marked as invalid.
    • isInMemory

      public abstract boolean isInMemory()
      Returns true if uploaded file content is stored in memory.
    • processStream

      protected abstract void processStream() throws IOException
      Process request input stream. Note that file size is unknown at this point. Therefore, the implementation should set the size attribute after successful processing. This method also must set the valid attribute.
      Throws:
      IOException
      See Also:
    • toString

      public String toString()
      Returns basic information about the uploaded file.
      Overrides:
      toString in class Object