public class FormDataMultiPart extends MultiPart
Subclass of MultiPart with specialized support for media type
multipart/form-data. See
RFC 2388
for the formal definition of this media type.
For a server side application wishing to process an incoming
multipart/form-data message, the following features
are provided:
FormDataMultiPart,
enabling access to the specialized methods.FormDataBodyPart,
enabling access to its specialized methods.FormDataBodyPart for a
specified control name.Map of FormDataBodyParts
for all fields, keyed by field name.For a client side application wishing to construct an outgoing
multipart/form-data message, the following features
are provided:
FormDataMultiPart instance will automatically
set to multipart/form-data.text/plain.FIXME - Consider supporting the use case of a nested
multipart/mixed body part to contain multiple uploaded files.
| Constructor and Description |
|---|
FormDataMultiPart()
Instantiate a new
FormDataMultiPart instance with
default characteristics. |
| Modifier and Type | Method and Description |
|---|---|
FormDataMultiPart |
field(java.lang.String name,
java.lang.Object entity,
MediaType mediaType)
Builder pattern method to add a named field with an arbitrary
media type and entity, and return this instance.
|
FormDataMultiPart |
field(java.lang.String name,
java.lang.String value)
Builder pattern method to add a named field with a text value,
and return this instance.
|
FormDataBodyPart |
getField(java.lang.String name)
Get a form data body part given a control name.
|
java.util.Map<java.lang.String,java.util.List<FormDataBodyPart>> |
getFields()
Get a map of form data body parts where the key is the control name
and the value is a list of one or more form data body parts.
|
java.util.List<FormDataBodyPart> |
getFields(java.lang.String name)
Get a list of one or more form data body parts given a control name.
|
void |
setMediaType(MediaType mediaType)
Disable changing the media type to anything other than
multipart/form-data. |
bodyPart, bodyPart, cleanup, close, entity, getBodyParts, getEntity, setEntity, typecontentDisposition, getContentDisposition, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setContentDisposition, setParent, setProviderspublic FormDataMultiPart()
FormDataMultiPart instance with
default characteristics.public FormDataMultiPart field(java.lang.String name, java.lang.String value)
name - the control namevalue - the text valuepublic FormDataMultiPart field(java.lang.String name, java.lang.Object entity, MediaType mediaType)
name - the control name.entity - entity value for the new fieldmediaType - media type for the new fieldpublic FormDataBodyPart getField(java.lang.String name)
name - the control name.public java.util.List<FormDataBodyPart> getFields(java.lang.String name)
name - the control name.public java.util.Map<java.lang.String,java.util.List<FormDataBodyPart>> getFields()
public void setMediaType(MediaType mediaType)
multipart/form-data.setMediaType in class MultiPartmediaType - The proposed media typejava.lang.IllegalArgumentException - if the proposed media type is not
multipart/form-dataCopyright © 2016 Oracle Corporation. All Rights Reserved.