Class MultipartEntityBuilder


  • public class MultipartEntityBuilder
    extends java.lang.Object
    Builder for multipart HttpEntitys.
    Since:
    5.0
    • Field Detail

      • MULTIPART_CHARS

        private static final char[] MULTIPART_CHARS
        The pool of ASCII chars to be used for generating a multipart boundary.
      • contentType

        private org.apache.hc.core5.http.ContentType contentType
      • boundary

        private java.lang.String boundary
      • charset

        private java.nio.charset.Charset charset
      • multipartParts

        private java.util.List<MultipartPart> multipartParts
      • preamble

        private java.lang.String preamble
        The preamble of the multipart message. This field stores the optional preamble that should be added at the beginning of the multipart message. It can be null if no preamble is needed.
      • epilogue

        private java.lang.String epilogue
        The epilogue of the multipart message. This field stores the optional epilogue that should be added at the end of the multipart message. It can be null if no epilogue is needed.
      • EMPTY_NAME_VALUE_ARRAY

        private static final org.apache.hc.core5.http.NameValuePair[] EMPTY_NAME_VALUE_ARRAY
        An empty immutable NameValuePair array.
    • Constructor Detail

      • MultipartEntityBuilder

        MultipartEntityBuilder()
    • Method Detail

      • setContentType

        public MultipartEntityBuilder setContentType​(org.apache.hc.core5.http.ContentType contentType)
        Since:
        4.5
      • addParameter

        public MultipartEntityBuilder addParameter​(org.apache.hc.core5.http.message.BasicNameValuePair parameter)
        Add parameter to the current ContentType.
        Parameters:
        parameter - The name-value pair parameter to add to the ContentType.
        Returns:
        the MultipartEntityBuilder instance.
        Since:
        5.2
      • addTextBody

        public MultipartEntityBuilder addTextBody​(java.lang.String name,
                                                  java.lang.String text,
                                                  org.apache.hc.core5.http.ContentType contentType)
      • addBinaryBody

        public MultipartEntityBuilder addBinaryBody​(java.lang.String name,
                                                    byte[] b,
                                                    org.apache.hc.core5.http.ContentType contentType,
                                                    java.lang.String filename)
      • addBinaryBody

        public MultipartEntityBuilder addBinaryBody​(java.lang.String name,
                                                    java.io.File file,
                                                    org.apache.hc.core5.http.ContentType contentType,
                                                    java.lang.String filename)
      • addBinaryBody

        public MultipartEntityBuilder addBinaryBody​(java.lang.String name,
                                                    java.io.InputStream stream,
                                                    org.apache.hc.core5.http.ContentType contentType,
                                                    java.lang.String filename)
      • addBinaryBody

        public MultipartEntityBuilder addBinaryBody​(java.lang.String name,
                                                    java.io.InputStream stream)
      • addPreamble

        public MultipartEntityBuilder addPreamble​(java.lang.String preamble)
        Adds a preamble to the multipart entity being constructed. The preamble is the text that appears before the first boundary delimiter. The preamble is optional and may be null.
        Parameters:
        preamble - The preamble text to add to the multipart entity
        Returns:
        This MultipartEntityBuilder instance, to allow for method chaining
        Since:
        5.3
      • addEpilogue

        public MultipartEntityBuilder addEpilogue​(java.lang.String epilogue)
        Adds an epilogue to the multipart entity being constructed. The epilogue is the text that appears after the last boundary delimiter. The epilogue is optional and may be null.
        Parameters:
        epilogue - The epilogue text to add to the multipart entity
        Returns:
        This MultipartEntityBuilder instance, to allow for method chaining
        Since:
        5.3
      • generateBoundary

        private java.lang.String generateBoundary()
      • build

        public org.apache.hc.core5.http.HttpEntity build()