Package com.oorian.html.multipartrequest
Class ClientFile
java.lang.Object
com.oorian.html.multipartrequest.ClientFile
Represents a file uploaded from a client browser via multipart form data.
This class encapsulates information about files uploaded through HTML forms, providing access to both the original filename and the local temporary file location.
ClientFile provides:
- Access to the original filename as provided by the client
- The local filesystem path where the uploaded file is stored
- The MIME content type of the uploaded file
- Methods to retrieve file size and content
-
Constructor Summary
ConstructorsConstructorDescriptionClientFile(String filename, String localFilename, String contentType) Constructs a new ClientFile with the specified file information. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getBytes()Reads and returns the entire contents of the uploaded file as a byte array.Gets the MIME content type of the uploaded file.Gets the local filesystem path where the uploaded file is stored.Gets the original filename as provided by the client's browser.longgetSize()Gets the size of the uploaded file in bytes.
-
Constructor Details
-
ClientFile
Constructs a new ClientFile with the specified file information.- Parameters:
filename- the original filename from the client browser.localFilename- the local filesystem path where the file is stored.contentType- the MIME content type of the uploaded file.
-
-
Method Details
-
getOriginalFilename
Gets the original filename as provided by the client's browser. This is the name of the file on the user's computer before upload.- Returns:
- the original client-side filename.
-
getLocalFilename
Gets the local filesystem path where the uploaded file is stored. This is typically a temporary location on the server.- Returns:
- the local server-side filepath.
-
getContentType
Gets the MIME content type of the uploaded file. The content type is provided by the browser during upload.- Returns:
- the MIME content type (e.g., "image/jpeg", "application/pdf").
-
getSize
public long getSize()Gets the size of the uploaded file in bytes.- Returns:
- the file size in bytes.
-
getBytes
Reads and returns the entire contents of the uploaded file as a byte array. Use with caution for large files as the entire file is loaded into memory.- Returns:
- byte array containing the file contents.
- Throws:
IOException- if an I/O error occurs reading the file.
-