Class CommonsMultipartFile

java.lang.Object
org.springframework.web.multipart.commons.CommonsMultipartFile
All Implemented Interfaces:
Serializable, org.springframework.core.io.InputStreamSource, org.springframework.web.multipart.MultipartFile

public class CommonsMultipartFile extends Object implements org.springframework.web.multipart.MultipartFile, Serializable
MultipartFile implementation for Apache Commons FileUpload.
Since:
29.09.2003
See Also:
  • Field Details

    • logger

      protected static final org.apache.commons.logging.Log logger
  • Constructor Details

    • CommonsMultipartFile

      public CommonsMultipartFile(org.apache.tomcat.util.http.fileupload.FileItem fileItem)
      Create an instance wrapping the given FileItem.
      Parameters:
      fileItem - the FileItem to wrap
  • Method Details

    • getFileItem

      public final org.apache.tomcat.util.http.fileupload.FileItem getFileItem()
      Return the underlying org.apache.commons.fileupload.FileItem instance. There is hardly any need to access this.
    • setPreserveFilename

      public void setPreserveFilename(boolean preserveFilename)
      Set whether to preserve the filename as sent by the client, not stripping off path information in getOriginalFilename().

      Default is "false", stripping off path information that may prefix the actual filename e.g. from Opera. Switch this to "true" for preserving the client-specified filename as-is, including potential path separators.

      Since:
      4.3.5
      See Also:
    • getName

      public String getName()
      Specified by:
      getName in interface org.springframework.web.multipart.MultipartFile
    • getOriginalFilename

      public String getOriginalFilename()
      Specified by:
      getOriginalFilename in interface org.springframework.web.multipart.MultipartFile
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface org.springframework.web.multipart.MultipartFile
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.springframework.web.multipart.MultipartFile
    • getSize

      public long getSize()
      Specified by:
      getSize in interface org.springframework.web.multipart.MultipartFile
    • getBytes

      public byte[] getBytes()
      Specified by:
      getBytes in interface org.springframework.web.multipart.MultipartFile
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface org.springframework.core.io.InputStreamSource
      Specified by:
      getInputStream in interface org.springframework.web.multipart.MultipartFile
      Throws:
      IOException
    • transferTo

      public void transferTo(File dest) throws IOException, IllegalStateException
      Specified by:
      transferTo in interface org.springframework.web.multipart.MultipartFile
      Throws:
      IOException
      IllegalStateException
    • transferTo

      public void transferTo(Path dest) throws IOException, IllegalStateException
      Specified by:
      transferTo in interface org.springframework.web.multipart.MultipartFile
      Throws:
      IOException
      IllegalStateException
    • isAvailable

      protected boolean isAvailable()
      Determine whether the multipart content is still available. If a temporary file has been moved, the content is no longer available.
    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object