Class MultipartEntityBuilder
java.lang.Object
org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder
Builder for multipart
HttpEntity
s.- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private Charset
private org.apache.hc.core5.http.ContentType
private static final org.apache.hc.core5.http.NameValuePair[]
An empty immutableNameValuePair
array.private String
The epilogue of the multipart message.private HttpMultipartMode
private static final char[]
The pool of ASCII chars to be used for generating a multipart boundary.private List
<MultipartPart> private String
The preamble of the multipart message. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBinaryBody
(String name, byte[] b) addBinaryBody
(String name, byte[] b, org.apache.hc.core5.http.ContentType contentType, String filename) addBinaryBody
(String name, File file) addBinaryBody
(String name, File file, org.apache.hc.core5.http.ContentType contentType, String filename) addBinaryBody
(String name, InputStream stream) addBinaryBody
(String name, InputStream stream, org.apache.hc.core5.http.ContentType contentType, String filename) addEpilogue
(String epilogue) Adds an epilogue to the multipart entity being constructed.addParameter
(org.apache.hc.core5.http.message.BasicNameValuePair parameter) Add parameter to the currentContentType
.addPart
(String name, ContentBody contentBody) addPart
(MultipartPart multipartPart) addPreamble
(String preamble) Adds a preamble to the multipart entity being constructed.addTextBody
(String name, String text) addTextBody
(String name, String text, org.apache.hc.core5.http.ContentType contentType) org.apache.hc.core5.http.HttpEntity
build()
(package private) MultipartFormEntity
static MultipartEntityBuilder
create()
private String
setBoundary
(String boundary) setCharset
(Charset charset) setContentType
(org.apache.hc.core5.http.ContentType contentType) setMimeSubtype
(String subType) setMode
(HttpMultipartMode mode)
-
Field Details
-
MULTIPART_CHARS
private static final char[] MULTIPART_CHARSThe pool of ASCII chars to be used for generating a multipart boundary. -
contentType
private org.apache.hc.core5.http.ContentType contentType -
mode
-
boundary
-
charset
-
multipartParts
-
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 benull
if no preamble is needed. -
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 benull
if no epilogue is needed. -
EMPTY_NAME_VALUE_ARRAY
private static final org.apache.hc.core5.http.NameValuePair[] EMPTY_NAME_VALUE_ARRAYAn empty immutableNameValuePair
array.
-
-
Constructor Details
-
MultipartEntityBuilder
MultipartEntityBuilder()
-
-
Method Details
-
create
-
setMode
-
setLaxMode
-
setStrictMode
-
setBoundary
-
setMimeSubtype
- Since:
- 4.4
-
setContentType
- Since:
- 4.5
-
addParameter
public MultipartEntityBuilder addParameter(org.apache.hc.core5.http.message.BasicNameValuePair parameter) Add parameter to the currentContentType
.- Parameters:
parameter
- The name-value pair parameter to add to theContentType
.- Returns:
- the
MultipartEntityBuilder
instance. - Since:
- 5.2
-
setCharset
-
addPart
- Since:
- 4.4
-
addPart
-
addTextBody
public MultipartEntityBuilder addTextBody(String name, String text, org.apache.hc.core5.http.ContentType contentType) -
addTextBody
-
addBinaryBody
public MultipartEntityBuilder addBinaryBody(String name, byte[] b, org.apache.hc.core5.http.ContentType contentType, String filename) -
addBinaryBody
-
addBinaryBody
public MultipartEntityBuilder addBinaryBody(String name, File file, org.apache.hc.core5.http.ContentType contentType, String filename) -
addBinaryBody
-
addBinaryBody
public MultipartEntityBuilder addBinaryBody(String name, InputStream stream, org.apache.hc.core5.http.ContentType contentType, String filename) -
addBinaryBody
-
addPreamble
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
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
-
buildEntity
MultipartFormEntity buildEntity() -
build
public org.apache.hc.core5.http.HttpEntity build()
-