Class CommonsMultipartFileParameter

java.lang.Object
com.aspectran.core.activity.request.FileParameter
com.aspectran.web.support.multipart.commons.CommonsMultipartFileParameter

public class CommonsMultipartFileParameter extends FileParameter
This class represents a file item that was received within a multipart/form-data POST request.

Created: 2008. 04. 11 PM 8:55:25

  • Constructor Details

    • CommonsMultipartFileParameter

      public CommonsMultipartFileParameter(@NonNull org.apache.commons.fileupload.FileItem fileItem)
      Create an instance wrapping the given FileItem.
      Parameters:
      fileItem - the FileItem to wrap
  • Method Details

    • getFile

      public File getFile()
      Overrides:
      getFile in class FileParameter
    • getContentType

      public String getContentType()
      Gets the content type of the data being uploaded. This is never null, and defaults to "content/unknown" when the mime type of the data couldn't be determined and was not set manually.
      Overrides:
      getContentType in class FileParameter
      Returns:
      the content type
    • getFileName

      public String getFileName()
      Returns the file name that was uploaded in the multipart form.
      Overrides:
      getFileName in class FileParameter
      Returns:
      the file name
    • getFileSize

      public long getFileSize()
      Returns the file size that was uploaded in the multipart form.
      Overrides:
      getFileSize in class FileParameter
      Returns:
      the file size
    • getInputStream

      public InputStream getInputStream() throws IOException
      Return an InputStream to read the contents of the file from.
      Overrides:
      getInputStream in class FileParameter
      Returns:
      the contents of the file as stream, or an empty stream if empty
      Throws:
      IOException - in case of access errors (if the temporary store fails)
    • getBytes

      public byte[] getBytes()
      Return an byte array to read the contents of the file from.
      Overrides:
      getBytes in class FileParameter
      Returns:
      the byte array
    • saveAs

      public File saveAs(File destFile, boolean overwrite) throws IOException
      Save an uploaded file as a given destination file.
      Overrides:
      saveAs in class FileParameter
      Parameters:
      destFile - the destination file
      overwrite - whether to overwrite if it already exists
      Returns:
      a saved file
      Throws:
      IOException - if an I/O error has occurred
    • renameTo

      public File renameTo(File destFile, boolean overwrite) throws IOException
      Overrides:
      renameTo in class FileParameter
      Throws:
      IOException
    • delete

      public void delete()
      Deletes the underlying Commons FileItem instances.
      Overrides:
      delete in class FileParameter
    • release

      public void release()
      Description copied from class: FileParameter
      Sets the access permission that allow write operations on the file associated with this FileParameter.
      Overrides:
      release in class FileParameter
    • getStorageDescription

      public String getStorageDescription()
      Return a description for the storage location of the multipart content. Tries to be as specific as possible: mentions the file location in case of a temporary file.
      Returns:
      a description for the storage location of the multipart content