public class MultipartEntityBuilder extends Object
HttpEntity
s.
IMPORTANT: it is responsibility of the caller to validate / sanitize content of body parts. For instance, when using an explicit boundary, it's the caller's responsibility to ensure the body parts do not contain the boundary value, which can prevent the consumer of the entity from correctly parsing / processing the body parts.
public static MultipartEntityBuilder create()
public MultipartEntityBuilder setMode(HttpMultipartMode mode)
public MultipartEntityBuilder setLaxMode()
public MultipartEntityBuilder setStrictMode()
public MultipartEntityBuilder setBoundary(String boundary)
public MultipartEntityBuilder setMimeSubtype(String subType)
public MultipartEntityBuilder setContentType(org.apache.hc.core5.http.ContentType contentType)
public MultipartEntityBuilder addParameter(org.apache.hc.core5.http.message.BasicNameValuePair parameter)
ContentType
.parameter
- The name-value pair parameter to add to the ContentType
.public MultipartEntityBuilder setCharset(Charset charset)
public MultipartEntityBuilder addPart(MultipartPart multipartPart)
public MultipartEntityBuilder addPart(String name, ContentBody contentBody)
public MultipartEntityBuilder addTextBody(String name, String text, org.apache.hc.core5.http.ContentType contentType)
public MultipartEntityBuilder addTextBody(String name, String text)
public MultipartEntityBuilder addBinaryBody(String name, byte[] b, org.apache.hc.core5.http.ContentType contentType, String filename)
public MultipartEntityBuilder addBinaryBody(String name, byte[] b)
public MultipartEntityBuilder addBinaryBody(String name, File file, org.apache.hc.core5.http.ContentType contentType, String filename)
public MultipartEntityBuilder addBinaryBody(String name, File file)
public MultipartEntityBuilder addBinaryBody(String name, InputStream stream, org.apache.hc.core5.http.ContentType contentType, String filename)
public MultipartEntityBuilder addBinaryBody(String name, InputStream stream)
public MultipartEntityBuilder addPreamble(String preamble)
preamble
- The preamble text to add to the multipart entitypublic MultipartEntityBuilder addEpilogue(String epilogue)
epilogue
- The epilogue text to add to the multipart entitypublic org.apache.hc.core5.http.HttpEntity build()
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.