Class PendingFileUpload
java.lang.Object
de.xima.fc.inbox.model.PendingFileUpload
- All Implemented Interfaces:
Serializable, AutoCloseable
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 Summary
ConstructorsConstructorDescriptionPendingFileUpload(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanstatic PendingFileUploadfromUploadedFile(org.primefaces.model.file.UploadedFile file) Creates aPendingFileUploadfrom anUploadedFile.The content type of the file, e.g.The original file name of the uploaded file, may be different from the file name on the file system.The path file on the file system with the data of the uploaded file.longThe size of the file in bytes.getId()The unique identifier of the pending file upload.inthashCode()
-
Constructor Details
-
PendingFileUpload
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
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
equals
-
getContentType
The content type of the file, e.g. "application/pdf".- Returns:
- The content type of the file.
-
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
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
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
-
fromUploadedFile
public static PendingFileUpload fromUploadedFile(org.primefaces.model.file.UploadedFile file) throws IOException Creates aPendingFileUploadfrom anUploadedFile. 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 ofPendingFileUploadwith the path to the temporary file and the file's metadata.- Parameters:
file- The uploaded file to create aPendingFileUploadfrom.- Returns:
- A new instance of
PendingFileUploadwith 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.
-