Class ByteArrayBody

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] data
      The contents of the file contained in this part.
      private java.lang.String filename
      The name of the file contained in this part.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteArrayBody​(byte[] data, java.lang.String filename)
      Creates a new ByteArrayBody.
      ByteArrayBody​(byte[] data, org.apache.hc.core5.http.ContentType contentType)
      Public constructor that creates a new ByteArrayBody.
      ByteArrayBody​(byte[] data, org.apache.hc.core5.http.ContentType contentType, java.lang.String filename)  
    • Field Detail

      • data

        private final byte[] data
        The contents of the file contained in this part.
      • filename

        private final java.lang.String filename
        The name of the file contained in this part.
    • Constructor Detail

      • ByteArrayBody

        public ByteArrayBody​(byte[] data,
                             org.apache.hc.core5.http.ContentType contentType,
                             java.lang.String filename)
        Since:
        4.3
      • ByteArrayBody

        public ByteArrayBody​(byte[] data,
                             org.apache.hc.core5.http.ContentType contentType)
        Public constructor that creates a new ByteArrayBody.
        Parameters:
        contentType - the ContentType
        data - the array of byte.
        Since:
        5.2
      • ByteArrayBody

        public ByteArrayBody​(byte[] data,
                             java.lang.String filename)
        Creates a new ByteArrayBody.
        Parameters:
        data - The contents of the file contained in this part.
        filename - The name of the file contained in this part.
    • Method Detail

      • getFilename

        public java.lang.String getFilename()
      • writeTo

        public void writeTo​(java.io.OutputStream out)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getCharset

        public java.lang.String getCharset()
        Description copied from interface: ContentDescriptor

        The body descriptors character set, defaulted appropriately for the MIME type.

        For TEXT types, this will be defaulted to us-ascii. For other types, when the charset parameter is missing this property will be null.

        Specified by:
        getCharset in interface ContentDescriptor
        Overrides:
        getCharset in class AbstractContentBody
        Returns:
        Character set, which has been parsed from the content-type definition. Not null for TEXT types, when unset will be set to default us-ascii. For other types, when unset, null will be returned.
      • 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.