Class 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 Summary

      Constructors 
      Constructor Description
      CommonsMultipartFileParameter​(org.apache.commons.fileupload.FileItem fileItem)
      Create an instance wrapping the given FileItem.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()
      Deletes the underlying Commons FileItem instances.
      byte[] getBytes()
      Return an byte array to read the contents of the file from.
      java.lang.String getContentType()
      Gets the content type of the data being uploaded.
      java.io.File getFile()  
      java.lang.String getFileName()
      Returns the file name that was uploaded in the multipart form.
      long getFileSize()
      Returns the file size that was uploaded in the multipart form.
      java.io.InputStream getInputStream()
      Return an InputStream to read the contents of the file from.
      java.lang.String getStorageDescription()
      Return a description for the storage location of the multipart content.
      void release()
      Sets the access permission that allow write operations on the file associated with this FileParameter.
      java.io.File renameTo​(java.io.File destFile, boolean overwrite)  
      java.io.File saveAs​(java.io.File destFile, boolean overwrite)
      Save an uploaded file as a given destination file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CommonsMultipartFileParameter

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

      • getContentType

        public java.lang.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 java.lang.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 java.io.InputStream getInputStream()
                                           throws java.io.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:
        java.io.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 java.io.File saveAs​(java.io.File destFile,
                                   boolean overwrite)
                            throws java.io.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:
        java.io.IOException - if an I/O error has occurred
      • renameTo

        public java.io.File renameTo​(java.io.File destFile,
                                     boolean overwrite)
                              throws java.io.IOException
        Overrides:
        renameTo in class FileParameter
        Throws:
        java.io.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 java.lang.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