Package de.xima.fc.inbox.model
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
equals(Object o)
static PendingFileUpload
fromUploadedFile(org.primefaces.model.file.UploadedFile file)
Creates aPendingFileUpload
from anUploadedFile
.String
getContentType()
The content type of the file, e.g.String
getFileName()
The original file name of the uploaded file, may be different from the file name on the file system.String
getFilePath()
The path file on the file system with the data of the uploaded file.long
getFileSize()
The size of the file in bytes.String
getId()
The unique identifier of the pending file upload.int
hashCode()
-
-
-
Constructor Detail
-
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 Detail
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
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.
-
fromUploadedFile
public static PendingFileUpload fromUploadedFile(org.primefaces.model.file.UploadedFile file) throws IOException
Creates aPendingFileUpload
from 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 ofPendingFileUpload
with the path to the temporary file and the file's metadata.- Parameters:
file
- The uploaded file to create aPendingFileUpload
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.
-
-