Class FileParameter

java.lang.Object
com.oorian.apis.FileParameter

public class FileParameter extends Object
Represents a file to be included in a multipart HTTP request.

Encapsulates the file data, name, content type, and optional parameter name for use with MultipartRequest subclasses.

  • Constructor Details

    • FileParameter

      public FileParameter(String paramName, File file) throws FileNotFoundException
      Creates a file parameter with a form field name and file.
      Parameters:
      paramName - the form field name.
      file - the file to upload.
      Throws:
      FileNotFoundException - if the file does not exist.
    • FileParameter

      public FileParameter(File file) throws FileNotFoundException
      Creates a file parameter from a file, using the file name as the parameter name.
      Parameters:
      file - the file to upload.
      Throws:
      FileNotFoundException - if the file does not exist.
    • FileParameter

      public FileParameter(String paramName, String fileName, FileInputStream fileInputStream)
      Creates a file parameter with a form field name, file name, and input stream.
      Parameters:
      paramName - the form field name.
      fileName - the file name.
      fileInputStream - the input stream containing the file data.
    • FileParameter

      public FileParameter(String fileName, FileInputStream fileInputStream)
      Creates a file parameter with a file name and input stream.
      Parameters:
      fileName - the file name.
      fileInputStream - the input stream containing the file data.
  • Method Details

    • setContentType

      public void setContentType(String contentType)
      Sets the content type for this file parameter.
      Parameters:
      contentType - the MIME content type.
    • getParamName

      public String getParamName()
      Returns the form field name for this file parameter.
      Returns:
      the parameter name.
    • getFileName

      public String getFileName()
      Returns the file name.
      Returns:
      the file name.
    • getFileInputStream

      public FileInputStream getFileInputStream() throws FileNotFoundException
      Returns the input stream for reading the file data.
      Returns:
      the file input stream.
      Throws:
      FileNotFoundException - if the file cannot be found.
    • getContentType

      public String getContentType()
      Returns the MIME content type of the file.
      Returns:
      the content type.
    • getFile

      public File getFile()
      Returns the file object, if one was provided.
      Returns:
      the file, or null if constructed from an input stream.