Class FormDataMultiPart
java.lang.Object
org.glassfish.jersey.media.multipart.BodyPart
org.glassfish.jersey.media.multipart.MultiPart
org.glassfish.jersey.media.multipart.FormDataMultiPart
- All Implemented Interfaces:
Closeable
,AutoCloseable
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:
- Incoming entities will be of type
FormDataMultiPart
, enabling access to the specialized methods. - Incoming body parts will be of type
FormDataBodyPart
, enabling access to its specialized methods. - Convenience method to return the
FormDataBodyPart
for a specified control name. - Convenience method to return a
Map
ofFormDataBodyPart
s for all fields, keyed by field name.
multipart/form-data
message, the following features
are provided:
- Media type of the
FormDataMultiPart
instance will automatically set tomultipart/form-data
. - Builder pattern method to add simple field values as body parts of type
text/plain
. - Builder pattern method to add named "file" field values with arbitrary media types.
multipart/mixed
body part to contain multiple uploaded files.- Author:
- Craig McClanahan, Imran M Yousuf (imran at smartitengineering.com), Paul Sandoz, Michal Gajdos
-
Field Summary
Fields inherited from class org.glassfish.jersey.media.multipart.BodyPart
contentDisposition, messageBodyWorkers
-
Constructor Summary
ConstructorDescriptionInstantiates a newFormDataMultiPart
instance with default characteristics. -
Method Summary
Modifier and TypeMethodDescriptionBuilder pattern method to add a named field with an arbitrary media type and entity, and return this instance.Builder pattern method to add a named field with a text value, and return this instance.Gets a form data body part given a control name.Gets 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.Gets a list of one or more form data body parts given a control name.void
setMediaType
(MediaType mediaType) Disables changing the media type to anything other thanmultipart/form-data
.Methods inherited from class org.glassfish.jersey.media.multipart.MultiPart
bodyPart, bodyPart, cleanup, close, entity, getBodyParts, getEntity, setEntity, type
Methods inherited from class org.glassfish.jersey.media.multipart.BodyPart
contentDisposition, getContentDisposition, getEntityAs, getHeaders, getMediaType, getParameterizedHeaders, getParent, getProviders, setContentDisposition, setMessageBodyWorkers, setParent, setProviders
-
Constructor Details
-
FormDataMultiPart
public FormDataMultiPart()Instantiates a newFormDataMultiPart
instance with default characteristics.
-
-
Method Details
-
field
Builder pattern method to add a named field with a text value, and return this instance.- Parameters:
name
- the control name.value
- the text value.- Returns:
- this instance.
-
field
Builder pattern method to add a named field with an arbitrary media type and entity, and return this instance.- Parameters:
name
- the control name.entity
- entity value for the new field.mediaType
- media type for the new field.- Returns:
- this instance.
-
getField
Gets a form data body part given a control name.- Parameters:
name
- the control name.- Returns:
- the form data body part, otherwise null if no part is present with the given control name. If more that one part is present with the same control name, then the first part that occurs is returned.
-
getFields
Gets a list of one or more form data body parts given a control name.- Parameters:
name
- the control name.- Returns:
- the list of form data body parts, otherwise null if no parts are present with the given control name.
-
getFields
Gets 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.- Returns:
- return the map of form data body parts.
-
setMediaType
Disables changing the media type to anything other thanmultipart/form-data
.- Overrides:
setMediaType
in classMultiPart
- Parameters:
mediaType
- the proposed media type.- Throws:
IllegalArgumentException
- if the proposed media type is notmultipart/form-data
.
-