Class AdaptiveFileUpload

java.lang.Object
jodd.http.upload.FileUpload
jodd.http.upload.impl.AdaptiveFileUpload

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

    • TMP_FILE_SUFFIX

      protected static final String TMP_FILE_SUFFIX
      See Also:
    • memoryThreshold

      protected final int memoryThreshold
    • uploadPath

      protected final File uploadPath
    • breakOnError

      protected final boolean breakOnError
    • fileExtensions

      protected final String[] fileExtensions
    • allowFileExtensions

      protected final boolean allowFileExtensions
    • tempFile

      protected File 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

      public File getUploadPath()
    • isBreakOnError

      public boolean isBreakOnError()
    • getFileExtensions

      public String[] getFileExtensions()
    • isAllowFileExtensions

      public boolean isAllowFileExtensions()
    • isInMemory

      public boolean isInMemory()
      Returns true if file upload resides in memory.
      Specified by:
      isInMemory in class FileUpload
    • matchFileExtension

      protected boolean matchFileExtension() throws IOException
      Throws:
      IOException
    • checkUpload

      protected boolean checkUpload() throws IOException
      Determines if upload is allowed.
      Throws:
      IOException
    • processStream

      protected void processStream() throws IOException
      Description copied from class: FileUpload
      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.
      Specified by:
      processStream in class FileUpload
      Throws:
      IOException
      See Also:
    • delete

      public void delete()
      Deletes file uploaded item from disk or memory.
    • write

      public File write(String destination) throws IOException
      Writes file uploaded item.
      Throws:
      IOException
    • write

      public File write(File destination) throws IOException
      Writes file upload item to destination folder or to destination file. Returns the destination file.
      Throws:
      IOException
    • getFileContent

      public byte[] getFileContent() throws IOException
      Returns the content of file upload item.
      Specified by:
      getFileContent in class FileUpload
      Throws:
      IOException
    • getFileInputStream

      public InputStream getFileInputStream() throws IOException
      Description copied from class: FileUpload
      Returns input stream of uploaded file.
      Specified by:
      getFileInputStream in class FileUpload
      Throws:
      IOException