org.apache.tomcat.util.http.fileupload.impl

## Class FileItemStreamImpl

- java.lang.Object
- - org.apache.tomcat.util.http.fileupload.impl.FileItemStreamImpl

- All Implemented Interfaces:
    FileItemHeadersSupport, FileItemStream

      public class FileItemStreamImpl
      extends Object
      implements FileItemStream

  Default implementation of `FileItemStream`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.tomcat.util.http.fileupload.FileItemStream

      `FileItemStream.ItemSkippedException`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileItemStreamImpl(FileItemIteratorImpl pFileItemIterator, String pName, String pFieldName, String pContentType, boolean pFormField, long pContentLength)` Creates a new instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the file item.
    `String` | `getContentType()` Returns the items content type, or null.
    `String` | `getFieldName()` Returns the items field name.
    `FileItemHeaders` | `getHeaders()` Returns the file item headers.
    `String` | `getName()` Returns the items file name.
    `boolean` | `isFormField()` Returns, whether this is a form field.
    `InputStream` | `openStream()` Returns an input stream, which may be used to read the items contents.
    `void` | `setHeaders(FileItemHeaders pHeaders)` Sets the file item headers.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileItemStreamImpl

          public FileItemStreamImpl(FileItemIteratorImpl pFileItemIterator,
                            String pName,
                            String pFieldName,
                            String pContentType,
                            boolean pFormField,
                            long pContentLength)
                             throws FileUploadException,
                                    IOException

      Creates a new instance.
      Parameters:
        `pFileItemIterator` - The `iterator`, which returned this file item.
        `pName` - The items file name, or null.
        `pFieldName` - The items field name.
        `pContentType` - The items content type, or null.
        `pFormField` - Whether the item is a form field.
        `pContentLength` - The items content length, if known, or -1
      Throws:
        `IOException` - Creating the file item failed.
        `FileUploadException` - Parsing the incoming data stream failed.

  - ### Method Detail

    - #### getContentType

          public String getContentType()

      Returns the items content type, or null.
      Specified by:
        `getContentType` in interface `FileItemStream`
      Returns:
        Content type, if known, or null.

    - #### getFieldName

          public String getFieldName()

      Returns the items field name.
      Specified by:
        `getFieldName` in interface `FileItemStream`
      Returns:
        Field name.

    - #### getName

          public String getName()

      Returns the items file name.
      Specified by:
        `getName` in interface `FileItemStream`
      Returns:
        File name, if known, or null.
      Throws:
        `InvalidFileNameException` - The file name contains a NUL character, which might be an indicator of a security attack. If you intend to use the file name anyways, catch the exception and use InvalidFileNameException#getName().

    - #### isFormField

          public boolean isFormField()

      Returns, whether this is a form field.
      Specified by:
        `isFormField` in interface `FileItemStream`
      Returns:
        True, if the item is a form field, otherwise false.

    - #### openStream

          public InputStream openStream()
                                 throws IOException

      Returns an input stream, which may be used to read the items contents.
      Specified by:
        `openStream` in interface `FileItemStream`
      Returns:
        Opened input stream.
      Throws:
        `IOException` - An I/O error occurred.
      See Also:
        `FileItemStream.ItemSkippedException`

    - #### close

          public void close()
                     throws IOException

      Closes the file item.
      Throws:
        `IOException` - An I/O error occurred.

    - #### getHeaders

          public FileItemHeaders getHeaders()

      Returns the file item headers.
      Specified by:
        `getHeaders` in interface `FileItemHeadersSupport`
      Returns:
        The items header object

    - #### setHeaders

          public void setHeaders(FileItemHeaders pHeaders)

      Sets the file item headers.
      Specified by:
        `setHeaders` in interface `FileItemHeadersSupport`
      Parameters:
        `pHeaders` - The items header object

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.