Package org.restlet.representation
Class MultiPartRepresentation
java.lang.Object
org.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.representation.StreamRepresentation
org.restlet.representation.InputRepresentation
org.restlet.representation.MultiPartRepresentation
Input representation that can either parse or generate a multipart form data
representation depending on which constructor is invoked.
- Author:
- Jerome Louvel
-
Field Summary
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionMultiPartRepresentation(String boundary, List<org.eclipse.jetty.http.MultiPart.Part> parts) Constructor that wraps multiple parts, set a boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.MultiPartRepresentation(String boundary, org.eclipse.jetty.http.MultiPart.Part... parts) Constructor that wraps multiple parts, set a boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.MultiPartRepresentation(List<org.eclipse.jetty.http.MultiPart.Part> parts) Constructor that wraps multiple parts, set a random boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.MultiPartRepresentation(org.eclipse.jetty.http.MultiPart.Part... parts) Constructor that wraps multiple parts, set a random boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.MultiPartRepresentation(MediaType mediaType, InputStream multiPartEntity, org.eclipse.jetty.http.MultiPartConfig config) Constructor that PARSES the content based on a given configuration intogetParts().MultiPartRepresentation(MediaType mediaType, String boundary, List<org.eclipse.jetty.http.MultiPart.Part> parts) Constructor that wraps multiple parts, set a media type with a boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.MultiPartRepresentation(Representation multiPartEntity, Path storageLocation) Constructor that PARSES the content based on a given configuration intogetParts().MultiPartRepresentation(Representation multiPartEntity, org.eclipse.jetty.http.MultiPartConfig config) Constructor that PARSES the content based on a given configuration intogetParts(). -
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.jetty.http.MultiPart.PartcreatePart(String name, String fileName, Representation partContent) Creates a #MultiPart.Partobject based on aRepresentationplus metadata.Returns the boundary used to separate each part for the parsed or generated form.static StringgetBoundary(MediaType mediaType) Returns the value of the first media-type parameter with "boundary" name.List<org.eclipse.jetty.http.MultiPart.Part> getParts()Returns the wrapped multipart form data either parsed or to be generated.Returns an input stream that generates the multipart form data serialization for the wrappedgetParts()object.voidsetBoundary(String boundary) Sets the boundary used to separate each part for the parsed or generated form.static MediaTypesetBoundary(MediaType mediaType, String boundary) Sets a boundary to an existing media type.Methods inherited from class org.restlet.representation.InputRepresentation
getText, release, setStream, writeMethods inherited from class org.restlet.representation.StreamRepresentation
getReader, writeMethods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getSize, hasKnownSize, isAvailable, isEmpty, isTransient, setAvailable, setDigest, setDisposition, setExpirationDate, setRange, setSize, setTransientMethods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTagMethods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
-
Constructor Details
-
MultiPartRepresentation
Constructor that wraps multiple parts, set a random boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.- Parameters:
parts- The source parts to use when generating the representation.
-
MultiPartRepresentation
public MultiPartRepresentation(MediaType mediaType, String boundary, List<org.eclipse.jetty.http.MultiPart.Part> parts) Constructor that wraps multiple parts, set a media type with a boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.- Parameters:
mediaType- The media type to set.boundary- The boundary to add as a parameter.parts- The source parts to use when generating the representation.
-
MultiPartRepresentation
public MultiPartRepresentation(org.eclipse.jetty.http.MultiPart.Part... parts) Constructor that wraps multiple parts, set a random boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.- Parameters:
parts- The source parts to use when generating the representation.
-
MultiPartRepresentation
public MultiPartRepresentation(Representation multiPartEntity, org.eclipse.jetty.http.MultiPartConfig config) throws IOException Constructor that PARSES the content based on a given configuration intogetParts().- Parameters:
multiPartEntity- The multipart entity to parse which should have a media type based onMediaType.MULTIPART_FORM_DATA, with a "boundary" parameter.config- The multipart configuration.- Throws:
IOException
-
MultiPartRepresentation
public MultiPartRepresentation(Representation multiPartEntity, Path storageLocation) throws IOException Constructor that PARSES the content based on a given configuration intogetParts(). Uses a defaultMultiPartConfig.- Parameters:
multiPartEntity- The multipart entity to parse which should have a media type based onMediaType.MULTIPART_FORM_DATA, with a "boundary" parameter.storageLocation- The location where parsed files are stored for easier access.- Throws:
IOException
-
MultiPartRepresentation
public MultiPartRepresentation(MediaType mediaType, InputStream multiPartEntity, org.eclipse.jetty.http.MultiPartConfig config) throws IOException Constructor that PARSES the content based on a given configuration intogetParts().- Parameters:
mediaType- The media type that should be based onMediaType.MULTIPART_FORM_DATA, with a "boundary" parameter.multiPartEntity- The multipart entity to parse.config- The multipart configuration.- Throws:
IOException
-
MultiPartRepresentation
Constructor that wraps multiple parts, set a boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.- Parameters:
boundary- The boundary to add as a parameter.parts- The source parts to use when generating the representation.
-
MultiPartRepresentation
Constructor that wraps multiple parts, set a boundary, then GENERATES the content viagetStream()as aMediaType.MULTIPART_FORM_DATA.- Parameters:
parts- The source parts to use when generating the representation.
-
-
Method Details
-
createPart
public static org.eclipse.jetty.http.MultiPart.Part createPart(String name, String fileName, Representation partContent) throws IOException Creates a #MultiPart.Partobject based on aRepresentationplus metadata.- Parameters:
name- The name of the part.fileName- The client suggests file name for storing the part.partContent- The part content.- Returns:
- The Jetty #
MultiPart.Partobject created. - Throws:
IOException
-
getBoundary
Returns the value of the first media-type parameter with "boundary" name.- Parameters:
mediaType- The media type that might contain a "boundary" parameter.- Returns:
- The value of the first media-type parameter with "boundary" name.
-
setBoundary
Sets a boundary to an existing media type. If the original mediatype already has a "boundary" parameter, it will be erased. *- Parameters:
mediaType- The media type to update.boundary- The boundary to add as a parameter.- Returns:
- The updated media type.
-
getBoundary
Returns the boundary used to separate each part for the parsed or generated form.- Returns:
- The boundary used to separate each part for the parsed or generated form.
-
getParts
Returns the wrapped multipart form data either parsed or to be generated.- Returns:
- The wrapped multipart form data either parsed or to be generated.
-
getStream
Returns an input stream that generates the multipart form data serialization for the wrappedgetParts()object. The "boundary" must be non-null when invoking this method.- Overrides:
getStreamin classInputRepresentation- Returns:
- An input stream that generates the multipart form data.
- Throws:
IOException
-
setBoundary
Sets the boundary used to separate each part for the parsed or generated form. It will also update theMediaType's "boundary" attribute.- Parameters:
boundary- The boundary used to separate each part for the parsed or generated form.
-