Class PendingFileUpload

java.lang.Object
de.xima.fc.inbox.model.PendingFileUpload
All Implemented Interfaces:
Serializable, AutoCloseable

public final class PendingFileUpload extends Object implements AutoCloseable, Serializable
Model for a file that was uploaded to the server and stored in a bean, but not yet written to the database.
Since:
8.2.3
See Also:
  • Constructor Details

    • PendingFileUpload

      public PendingFileUpload(String filePath, String fileName, long fileSize, String contentType)
      Creates a new pending file upload with the given file path, file name, file size and content type.
      Parameters:
      filePath - The path to the file on the file system.
      fileName - The original file name of the uploaded file, may be different from the file name on the file system.
      fileSize - The size of the file in bytes.
      contentType - The content type of the file, e.g. "application/pdf".
  • Method Details

    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getContentType

      public String getContentType()
      The content type of the file, e.g. "application/pdf".
      Returns:
      The content type of the file.
    • getFileName

      public String getFileName()
      The original file name of the uploaded file, may be different from the file name on the file system.
      Returns:
      The original file name of the uploaded file.
    • getFilePath

      public String getFilePath()
      The path file on the file system with the data of the uploaded file.
      Returns:
      The file on the file system with the data of the uploaded file.
    • getFileSize

      public long getFileSize()
      The size of the file in bytes.
      Returns:
      The size of the file in bytes.
    • getId

      public String getId()
      The unique identifier of the pending file upload. Can be used e.g. to remove a pending file upload from a list of pending file uploads.
      Returns:
      The unique identifier of the pending file upload.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fromUploadedFile

      public static PendingFileUpload fromUploadedFile(org.primefaces.model.file.UploadedFile file) throws IOException
      Creates a PendingFileUpload from an UploadedFile. Creates a temporary file in the application's temp directory, copies the content of the uploaded file to the temporary file and returns a new instance of PendingFileUpload with the path to the temporary file and the file's metadata.
      Parameters:
      file - The uploaded file to create a PendingFileUpload from.
      Returns:
      A new instance of PendingFileUpload with the path to the temporary file and the file's metadata.
      Throws:
      IOException - If an I/O error occurs while copying the content of the uploaded file to the temporary file.