Class ByteArrayBody

  • All Implemented Interfaces:
    ContentBody

    public class ByteArrayBody
    extends AbstractContentBody
    Binary body part backed by a byte array.
    Since:
    4.1
    See Also:
    org.apache.http.entity.mime.MultipartEntityBuilder
    • Constructor Detail

      • ByteArrayBody

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

        public ByteArrayBody​(byte[] data,
                             ContentType contentType,
                             String filename)
        Since:
        4.3
      • ByteArrayBody

        public ByteArrayBody​(byte[] data,
                             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 String getFilename()
      • getCharset

        public String getCharset()
        Description copied from interface: ContentBody

        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 ContentBody
        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.
      • getTransferEncoding

        public String getTransferEncoding()
        Description copied from interface: ContentBody
        Returns the body descriptors transfer encoding.
        Returns:
        The transfer encoding. Must not be null, but "7bit", if no transfer-encoding was specified.
      • getContentLength

        public long getContentLength()
        Description copied from interface: ContentBody
        Returns the body descriptors content-length.
        Returns:
        Content length, if known, or -1, to indicate the absence of a content-length header.