Class MultiPartFormInputStream


  • public class MultiPartFormInputStream
    extends java.lang.Object
    MultiPartInputStream

    Handle a MultiPart Mime input stream, breaking it up on the boundary into files and strings.

    See Also:
    https://tools.ietf.org/html/rfc7578
    • Field Detail

      • LOG

        private static final Logger LOG
      • EMPTY_MAP

        private static final MultiMap<javax.servlet.http.Part> EMPTY_MAP
      • _parts

        private final MultiMap<javax.servlet.http.Part> _parts
      • _in

        private java.io.InputStream _in
      • _config

        private javax.servlet.MultipartConfigElement _config
      • _contentType

        private java.lang.String _contentType
      • _err

        private java.lang.Throwable _err
      • _tmpDir

        private java.io.File _tmpDir
      • _contextTmpDir

        private java.io.File _contextTmpDir
      • _deleteOnExit

        private boolean _deleteOnExit
      • _writeFilesWithFilenames

        private boolean _writeFilesWithFilenames
      • _parsed

        private boolean _parsed
      • _bufferSize

        private int _bufferSize
    • Constructor Detail

      • MultiPartFormInputStream

        public MultiPartFormInputStream​(java.io.InputStream in,
                                        java.lang.String contentType,
                                        javax.servlet.MultipartConfigElement config,
                                        java.io.File contextTmpDir)
        Parameters:
        in - Request input stream
        contentType - Content-Type header
        config - MultipartConfigElement
        contextTmpDir - javax.servlet.context.tempdir
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Returns:
        whether the list of parsed parts is empty
      • getParsedParts

        @Deprecated
        public java.util.Collection<javax.servlet.http.Part> getParsedParts()
        Deprecated.
        Get the already parsed parts.
        Returns:
        the parts that were parsed
      • deleteParts

        public void deleteParts()
        Delete any tmp storage for parts, and clear out the parts list.
      • getParts

        public java.util.Collection<javax.servlet.http.Part> getParts()
                                                               throws java.io.IOException
        Parse, if necessary, the multipart data and return the list of Parts.
        Returns:
        the parts
        Throws:
        java.io.IOException - if unable to get the parts
      • getPart

        public javax.servlet.http.Part getPart​(java.lang.String name)
                                        throws java.io.IOException
        Get the named Part.
        Parameters:
        name - the part name
        Returns:
        the parts
        Throws:
        java.io.IOException - if unable to get the part
      • throwIfError

        protected void throwIfError()
                             throws java.io.IOException
        Throws an exception if one has been latched.
        Throws:
        java.io.IOException - the exception (if present)
      • parse

        protected void parse()
        Parse, if necessary, the multipart stream.
      • setDeleteOnExit

        public void setDeleteOnExit​(boolean deleteOnExit)
      • setWriteFilesWithFilenames

        public void setWriteFilesWithFilenames​(boolean writeFilesWithFilenames)
      • isWriteFilesWithFilenames

        public boolean isWriteFilesWithFilenames()
      • isDeleteOnExit

        public boolean isDeleteOnExit()
      • value

        private static java.lang.String value​(java.lang.String nameEqualsValue)
      • filenameValue

        private static java.lang.String filenameValue​(java.lang.String nameEqualsValue)
      • getBufferSize

        public int getBufferSize()
        Returns:
        the size of buffer used to read data from the input stream
      • setBufferSize

        public void setBufferSize​(int bufferSize)
        Parameters:
        bufferSize - the size of buffer used to read data from the input stream