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.lang.Stringboundaryprivate java.nio.charset.CharsetcharSetprivate booleanforceMultiprivate MultipartModemodeprivate ProgressMonitormonitorprivate 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)HttpRequestMultiPart(HttpRequestMultiPart httpRequest)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddPart(java.lang.String name, java.lang.Object value, java.lang.String contentType)private voidaddPart(BodyPart value)MultipartBodyboundary(java.lang.String boundaryIdentifier)Sets the value to use as the boundary identifier.MultipartBodycharset(java.nio.charset.Charset charset)Set the encoding of the request bodyMultipartBodycontentType(java.lang.String mimeType)Set the mime-type of the request bodyMultipartBodyfield(java.lang.String name, byte[] bytes, java.lang.String fileName)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, byte[] bytes, ContentType contentType, java.lang.String fileName)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.io.File file)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.io.File file, java.lang.String contentType)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.io.InputStream stream, java.lang.String fileName)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.io.InputStream value, ContentType contentType)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.io.InputStream stream, ContentType contentType, java.lang.String fileName)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.lang.Object value, java.lang.String contentType)MultipartBodyfield(java.lang.String name, java.lang.String value)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.lang.String value, java.lang.String contentType)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.lang.String value, ContentType contentType)add a simple field with a name and valueMultipartBodyfield(java.lang.String name, java.util.Collection<?> collection)add a simple field with a name and valueMultipartBodyfields(java.util.Map<java.lang.String,java.lang.Object> fields)(package private) MultipartBodyforceMultiPart(boolean value)java.util.Optional<Body>getBody()java.lang.StringgetBoundary()java.nio.charset.CharsetgetCharset()MultipartModegetMode()ProgressMonitorgetMonitor()booleanisEntityBody()booleanisMultiPart()MultipartBodymode(MultipartMode value)Set the Apache Mode.java.util.Collection<BodyPart>multiParts()MultipartBodyuploadMonitor(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, cookie, cookie, cookie, downloadMonitor, equals, getCreationTime, getDownloadMonitor, getHeaders, getHttpMethod, getObjectMapper, getPath, getRequestTimeout, getUrl, getVersion, hashCode, header, headerReplace, headers, headersReplace, queryString, queryString, queryString, requestTimeout, 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, 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, cookie, cookie, cookie, downloadMonitor, getCreationTime, getHeaders, getHttpMethod, getRequestTimeout, getUrl, getVersion, header, headerReplace, headers, headersReplace, queryString, queryString, queryString, requestTimeout, 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
-
boundary
private java.lang.String boundary
-
-
Constructor Detail
-
HttpRequestMultiPart
HttpRequestMultiPart(HttpRequestBody httpRequest)
-
HttpRequestMultiPart
HttpRequestMultiPart(HttpRequestMultiPart httpRequest)
-
-
Method Detail
-
field
public MultipartBody field(java.lang.String name, java.lang.String value)
Description copied from interface:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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.lang.String value, ContentType contentType)
Description copied from interface:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodyadd a simple field with a name and value- Specified by:
fieldin 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:MultipartBodySet the encoding of the request body- Specified by:
charsetin 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:MultipartBodySet the mime-type of the request body- Specified by:
contentTypein interfaceMultipartBody- Parameters:
mimeType- the mime type of the body- Returns:
- The same MultipartBody
-
mode
public MultipartBody mode(MultipartMode value)
Description copied from interface:MultipartBodySet the Apache Mode.- Specified by:
modein interfaceMultipartBody- Parameters:
value- the value of the mode- Returns:
- The same MultipartBody
-
uploadMonitor
public MultipartBody uploadMonitor(ProgressMonitor uploadMonitor)
Description copied from interface:MultipartBodySet a file Progress upload monitor suitable for drawing progress bars and whatnot.- Specified by:
uploadMonitorin interfaceMultipartBody- Parameters:
uploadMonitor- a monitor- Returns:
- The same MultipartBody
-
boundary
public MultipartBody boundary(java.lang.String boundaryIdentifier)
Description copied from interface:MultipartBodySets the value to use as the boundary identifier. see https://datatracker.ietf.org/doc/html/rfc2046- Specified by:
boundaryin interfaceMultipartBody- Parameters:
boundaryIdentifier- the value- Returns:
- The same MultipartBody
-
getBoundary
public java.lang.String getBoundary()
- Specified by:
getBoundaryin interfaceBody
-
getCharset
public java.nio.charset.Charset getCharset()
- Specified by:
getCharsetin 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:
getBodyin interfaceHttpRequest<MultipartBody>- Returns:
- if the request has a body it will be here.
-
isMultiPart
public boolean isMultiPart()
- Specified by:
isMultiPartin interfaceBody
-
isEntityBody
public boolean isEntityBody()
- Specified by:
isEntityBodyin interfaceBody
-
multiParts
public java.util.Collection<BodyPart> multiParts()
- Specified by:
multiPartsin interfaceBody
-
getMode
public MultipartMode getMode()
-
getMonitor
public ProgressMonitor getMonitor()
- Specified by:
getMonitorin interfaceBody
-
forceMultiPart
MultipartBody forceMultiPart(boolean value)
-
-