Package kong.unirest.core
Class HttpRequestMultiPart
- java.lang.Object
-
- kong.unirest.core.BaseRequest<MultipartBody>
-
- kong.unirest.core.HttpRequestMultiPart
-
- All Implemented Interfaces:
Body
,HttpRequest<MultipartBody>
,MultipartBody
class HttpRequestMultiPart extends BaseRequest<MultipartBody> implements MultipartBody
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.charset.Charset
charSet
private boolean
forceMulti
private MultipartMode
mode
private ProgressMonitor
monitor
private java.util.List<BodyPart>
parameters
-
Fields inherited from class kong.unirest.core.BaseRequest
config, headers, method, url
-
-
Constructor Summary
Constructors Constructor Description HttpRequestMultiPart(HttpRequestBody httpRequest)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addPart(java.lang.String name, java.lang.Object value, java.lang.String contentType)
private void
addPart(BodyPart value)
MultipartBody
charset(java.nio.charset.Charset charset)
Set the encoding of the request bodyMultipartBody
contentType(java.lang.String mimeType)
Set the mime-type of the request bodyMultipartBody
field(java.lang.String name, byte[] bytes, java.lang.String fileName)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, byte[] bytes, ContentType contentType, java.lang.String fileName)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.io.File file)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.io.File file, java.lang.String contentType)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.io.InputStream stream, java.lang.String fileName)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.io.InputStream value, ContentType contentType)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.io.InputStream stream, ContentType contentType, java.lang.String fileName)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.lang.Object value, java.lang.String contentType)
MultipartBody
field(java.lang.String name, java.lang.String value)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.lang.String value, java.lang.String contentType)
add a simple field with a name and valueMultipartBody
field(java.lang.String name, java.util.Collection<?> collection)
add a simple field with a name and valueMultipartBody
fields(java.util.Map<java.lang.String,java.lang.Object> fields)
(package private) MultipartBody
forceMultiPart(boolean value)
java.util.Optional<Body>
getBody()
java.nio.charset.Charset
getCharset()
MultipartMode
getMode()
ProgressMonitor
getMonitor()
boolean
isEntityBody()
boolean
isMultiPart()
MultipartBody
mode(MultipartMode value)
Set the Apache Mode.java.util.Collection<BodyPart>
multiParts()
MultipartBody
uploadMonitor(ProgressMonitor uploadMonitor)
Set a file Progress upload monitor suitable for drawing progress bars and whatnot.-
Methods inherited from class kong.unirest.core.BaseRequest
accept, asBytes, asBytesAsync, asBytesAsync, asEmpty, asEmptyAsync, asEmptyAsync, asFile, asFileAsync, asFileAsync, asJson, asJsonAsync, asJsonAsync, asObject, asObject, asObject, asObjectAsync, asObjectAsync, asObjectAsync, asObjectAsync, asObjectAsync, asPaged, asString, asStringAsync, asStringAsync, basicAuth, connectTimeout, cookie, cookie, cookie, downloadMonitor, equals, getConnectTimeout, getCreationTime, getHeaders, getHttpMethod, getObjectMapper, getPath, getUrl, getVersion, hashCode, header, headerReplace, headers, headersReplace, queryString, queryString, queryString, responseEncoding, routeParam, routeParam, thenConsume, thenConsumeAsync, toSummary, version, withObjectMapper
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface kong.unirest.core.HttpRequest
accept, asBytes, asBytesAsync, asBytesAsync, asEmpty, asEmptyAsync, asEmptyAsync, asFile, asFileAsync, asFileAsync, asJson, asJsonAsync, asJsonAsync, asObject, asObject, asObject, asObjectAsync, asObjectAsync, asObjectAsync, asObjectAsync, asObjectAsync, asPaged, asString, asStringAsync, asStringAsync, basicAuth, connectTimeout, cookie, cookie, cookie, downloadMonitor, getConnectTimeout, getCreationTime, getHeaders, getHttpMethod, getUrl, getVersion, header, headerReplace, headers, headersReplace, queryString, queryString, queryString, responseEncoding, routeParam, routeParam, thenConsume, thenConsumeAsync, toSummary, version, withObjectMapper
-
-
-
-
Field Detail
-
parameters
private java.util.List<BodyPart> parameters
-
mode
private MultipartMode mode
-
charSet
private java.nio.charset.Charset charSet
-
forceMulti
private boolean forceMulti
-
monitor
private ProgressMonitor monitor
-
-
Constructor Detail
-
HttpRequestMultiPart
HttpRequestMultiPart(HttpRequestBody httpRequest)
-
-
Method Detail
-
field
public MultipartBody field(java.lang.String name, java.lang.String value)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldvalue
- : The string value for the field- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.lang.String value, java.lang.String contentType)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldvalue
- : The string value for the fieldcontentType
- : the content type of the value- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.util.Collection<?> collection)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldcollection
- : A collection of values for the same name.- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.io.InputStream value, ContentType contentType)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldvalue
- : A input streamcontentType
- : the content mime-type of the file- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.io.File file)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldfile
- : A File object.- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.io.File file, java.lang.String contentType)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldfile
- : A File object.contentType
- : the content mime-type of the file- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.io.InputStream stream, ContentType contentType, java.lang.String fileName)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldstream
- : A input streamcontentType
- : the content mime-type of the filefileName
- : the name of the file which will be included in the file part header- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, java.io.InputStream stream, java.lang.String fileName)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldstream
- : The raw bytes for the filefileName
- : the name of the file which will be included in the file part header- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, byte[] bytes, ContentType contentType, java.lang.String fileName)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldbytes
- : The raw bytes for the filecontentType
- : the content mime-type of the filefileName
- : the name of the file which will be included in the file part header- Returns:
- The same MultipartBody
-
field
public MultipartBody field(java.lang.String name, byte[] bytes, java.lang.String fileName)
Description copied from interface:MultipartBody
add a simple field with a name and value- Specified by:
field
in interfaceMultipartBody
- Parameters:
name
- : the Name of the form fieldbytes
- : The raw bytes for the filefileName
- : the name of the file which will be included in the file part header- Returns:
- The same MultipartBody
-
charset
public MultipartBody charset(java.nio.charset.Charset charset)
Description copied from interface:MultipartBody
Set the encoding of the request body- Specified by:
charset
in interfaceMultipartBody
- Parameters:
charset
- the character set encoding of the body- Returns:
- The same MultipartBody
-
contentType
public MultipartBody contentType(java.lang.String mimeType)
Description copied from interface:MultipartBody
Set the mime-type of the request body- Specified by:
contentType
in interfaceMultipartBody
- Parameters:
mimeType
- the mime type of the body- Returns:
- The same MultipartBody
-
mode
public MultipartBody mode(MultipartMode value)
Description copied from interface:MultipartBody
Set the Apache Mode.- Specified by:
mode
in interfaceMultipartBody
- Parameters:
value
- the value of the mode- Returns:
- The same MultipartBody
-
uploadMonitor
public MultipartBody uploadMonitor(ProgressMonitor uploadMonitor)
Description copied from interface:MultipartBody
Set a file Progress upload monitor suitable for drawing progress bars and whatnot.- Specified by:
uploadMonitor
in interfaceMultipartBody
- Parameters:
uploadMonitor
- a monitor- Returns:
- The same MultipartBody
-
getCharset
public java.nio.charset.Charset getCharset()
- Specified by:
getCharset
in interfaceBody
-
fields
public MultipartBody fields(java.util.Map<java.lang.String,java.lang.Object> fields)
-
field
public MultipartBody field(java.lang.String name, java.lang.Object value, java.lang.String contentType)
-
addPart
private void addPart(java.lang.String name, java.lang.Object value, java.lang.String contentType)
-
addPart
private void addPart(BodyPart value)
-
getBody
public java.util.Optional<Body> getBody()
- Specified by:
getBody
in interfaceHttpRequest<MultipartBody>
- Returns:
- if the request has a body it will be here.
-
isMultiPart
public boolean isMultiPart()
- Specified by:
isMultiPart
in interfaceBody
-
isEntityBody
public boolean isEntityBody()
- Specified by:
isEntityBody
in interfaceBody
-
multiParts
public java.util.Collection<BodyPart> multiParts()
- Specified by:
multiParts
in interfaceBody
-
getMode
public MultipartMode getMode()
-
getMonitor
public ProgressMonitor getMonitor()
- Specified by:
getMonitor
in interfaceBody
-
forceMultiPart
MultipartBody forceMultiPart(boolean value)
-
-