public class Multipart
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MULTIPART_ENCODING |
| Constructor and Description |
|---|
Multipart()
Create a new multipart object
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFilePart(java.lang.String name,
java.lang.String contentType,
java.io.File file)
Add a file part to the multipart body
|
void |
addFormData(java.lang.String name,
java.lang.String contentType,
byte[] byteArray)
Add a part to the multipart body
|
void |
addHtmlPart(java.lang.String name,
byte[] content)
Add an HTML part to the multipart body
|
void |
addPart(java.util.Map<java.lang.String,java.lang.String> headers,
byte[] content)
Add a part to the multipart body
|
void |
addPart(java.lang.String contentType,
byte[] byteArray)
Add a part to the multipart body
|
byte[] |
content()
Returns a full multipart body byte array
|
static java.lang.String |
createContentHeaderValue(java.lang.String contentValue,
java.util.Map<java.lang.String,java.lang.String> contentDispParameter)
Create content headers value and parameter
|
java.lang.String |
getBoundary()
Get the multipart boundary for use in the request header
|
java.lang.String |
getContentType()
Get the contentType for use in the request header
|
HeaderOption |
header()
Get the Content-Type header to send the multipart request
|
void |
setBoundary(java.lang.String boundary)
Set the multipart boundary for use in the request header
|
void |
setContentType(java.lang.String contentType)
Set the contentType for use in the request header
|
public static final java.lang.String MULTIPART_ENCODING
public java.lang.String getBoundary()
public void setBoundary(java.lang.String boundary)
boundary - The multipart boundarypublic java.lang.String getContentType()
public void setContentType(java.lang.String contentType)
contentType - The multipart Content-Typepublic HeaderOption header()
public static java.lang.String createContentHeaderValue(java.lang.String contentValue,
java.util.Map<java.lang.String,java.lang.String> contentDispParameter)
contentValue - The content header valuecontentDispParameter - Map containing content paramter's key and value pairpublic void addFormData(java.lang.String name,
java.lang.String contentType,
byte[] byteArray)
throws java.io.IOException
name - The name of the partcontentType - The MIME type (text/html, video/mp4, etc.)byteArray - The byte[] contents of the resourcejava.io.IOException - Throws an exception if the output stream cannot be written topublic void addPart(java.lang.String contentType,
byte[] byteArray)
throws java.io.IOException
contentType - The MIME type (text/html, video/mp4, etc.)byteArray - The byte[] contents of the resourcejava.io.IOException - Throws an exception if the output stream cannot be written topublic void addPart(java.util.Map<java.lang.String,java.lang.String> headers,
byte[] content)
throws java.io.IOException
headers - Map containing Header's header-name(eg: Content-Disposition, Content-Type, etc..) and header's value-parameter stringcontent - The byte[] contents of the resourcejava.io.IOException - Throws an exception if the output stream cannot be written topublic void addHtmlPart(java.lang.String name,
byte[] content)
throws java.io.IOException
name - The name of the partcontent - The HTML body for the partjava.io.IOException - Throws an exception if the output stream cannot be written topublic void addFilePart(java.lang.String name,
java.lang.String contentType,
java.io.File file)
throws java.io.IOException
name - The name of the partcontentType - The MIME type of the file (application/pdf, video/mp4, etc.)file - The filejava.io.IOException - Throws an exception if the output stream cannot be written topublic byte[] content()
throws java.io.IOException
java.io.IOException - Throws an exception if the output stream cannot be written to