Class FileUpload

  • Direct Known Subclasses:
    AdaptiveFileUpload, DiskFileUpload, MemoryFileUpload

    public abstract class FileUpload
    extends java.lang.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 Detail

      • maxFileSize

        protected final int maxFileSize
      • valid

        protected boolean valid
      • size

        protected int size
      • fileTooBig

        protected boolean fileTooBig
    • Method Detail

      • getFileContent

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

        public abstract java.io.InputStream getFileInputStream()
                                                        throws java.io.IOException
        Returns input stream of uploaded file.
        Throws:
        java.io.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 java.io.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:
        java.io.IOException
        See Also:
        MultipartRequestInputStream
      • toString

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