org.apache.hc.client5.http.entity.mime

## Class InputStreamBody

- java.lang.Object
- - org.apache.hc.client5.http.entity.mime.AbstractContentBody
  - - org.apache.hc.client5.http.entity.mime.InputStreamBody

- All Implemented Interfaces:
    ContentBody, ContentDescriptor

      public class InputStreamBody
      extends AbstractContentBody

  Binary body part backed by an input stream.
  Since:
    4.0
  See Also:
    `MultipartEntityBuilder`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InputStreamBody(InputStream in, org.apache.hc.core5.http.ContentType contentType)`
    `InputStreamBody(InputStream in, org.apache.hc.core5.http.ContentType contentType, String filename)`
    `InputStreamBody(InputStream in, org.apache.hc.core5.http.ContentType contentType, String filename, long contentLength)`
    `InputStreamBody(InputStream in, String filename)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `getContentLength()` Returns the body descriptors content-length.
    `String` | `getFilename()`
    `InputStream` | `getInputStream()`
    `void` | `writeTo(OutputStream out)`

    - ### Methods inherited from class org.apache.hc.client5.http.entity.mime.AbstractContentBody

      `getCharset, getContentType, getMediaType, getMimeType, getSubType`

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

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

- - ### Constructor Detail

    - #### InputStreamBody

          public InputStreamBody(InputStream in,
                                 String filename)

    - #### InputStreamBody

          public InputStreamBody(InputStream in,
                                 org.apache.hc.core5.http.ContentType contentType,
                                 String filename)

      Since:
        4.3

    - #### InputStreamBody

          public InputStreamBody(InputStream in,
                                 org.apache.hc.core5.http.ContentType contentType,
                                 String filename,
                                 long contentLength)

      Since:
        4.6

    - #### InputStreamBody

          public InputStreamBody(InputStream in,
                                 org.apache.hc.core5.http.ContentType contentType)

      Since:
        4.3

  - ### Method Detail

    - #### getInputStream

          public InputStream getInputStream()

    - #### writeTo

          public void writeTo(OutputStream out)
                       throws IOException

      Throws:
        `IOException`

    - #### getContentLength

          public long getContentLength()

      Description copied from interface: `ContentDescriptor`
      Returns the body descriptors content-length.
      Returns:
        Content length, if known, or -1, to indicate the absence of a content-length header.

    - #### getFilename

          public String getFilename()

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.