Class ClientFile

java.lang.Object
com.oorian.html.multipartrequest.ClientFile

public class ClientFile extends Object
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 Details

    • ClientFile

      public ClientFile(String filename, String localFilename, String contentType)
      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

      public String 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

      public String 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

      public String 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

      public byte[] getBytes() throws IOException
      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.