org.apache.commons.fileupload

## Interface FileItemStream

- All Superinterfaces:
    FileItemHeadersSupport

      public interface FileItemStream
      extends FileItemHeadersSupport

  This interface provides access to a file or form item that was received within a `multipart/form-data` POST request. The items contents are retrieved by calling `openStream()`.

  Instances of this class are created by accessing the iterator, returned by `FileUploadBase.getItemIterator(RequestContext)`.

  Note: There is an interaction between the iterator and its associated instances of `FileItemStream`: By invoking `Iterator.hasNext()` on the iterator, you discard all data, which hasn't been read so far from the previous data.

  Version:
    $Id$

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `FileItemStream.ItemSkippedException` This exception is thrown, if an attempt is made to read data from the `InputStream`, which has been returned by `openStream()`, after `Iterator.hasNext()` has been invoked on the iterator, which created the `FileItemStream`.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getContentType()` Returns the content type passed by the browser or `null` if not defined.
    `String` | `getFieldName()` Returns the name of the field in the multipart form corresponding to this file item.
    `String` | `getName()` Returns the original filename in the client's filesystem, as provided by the browser (or other client software).
    `boolean` | `isFormField()` Determines whether or not a `FileItem` instance represents a simple form field.
    `InputStream` | `openStream()` Creates an `InputStream`, which allows to read the items contents.

    - ### Methods inherited from interface org.apache.commons.fileupload.FileItemHeadersSupport

      `getHeaders, setHeaders`

- - ### Method Detail

    - #### openStream

          InputStream openStream()
                          throws IOException

      Creates an `InputStream`, which allows to read the items contents.
      Returns:
        The input stream, from which the items data may be read.
      Throws:
        `IllegalStateException` - The method was already invoked on this item. It is not possible to recreate the data stream.
        `IOException` - An I/O error occurred.
      See Also:
        `FileItemStream.ItemSkippedException`

    - #### getContentType

          String getContentType()

      Returns the content type passed by the browser or `null` if not defined.
      Returns:
        The content type passed by the browser or `null` if not defined.

    - #### getName

          String getName()

      Returns the original filename in the client's filesystem, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.
      Returns:
        The original filename in the client's filesystem.

    - #### getFieldName

          String getFieldName()

      Returns the name of the field in the multipart form corresponding to this file item.
      Returns:
        The name of the form field.

    - #### isFormField

          boolean isFormField()

      Determines whether or not a `FileItem` instance represents a simple form field.
      Returns:
        `true` if the instance represents a simple form field; `false` if it represents an uploaded file.

Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.