Top Description Fields Constructors Methods
org.springframework.http.codec.multipart

public Class MultipartHttpMessageReader

extends LoggingCodecSupport
implements HttpMessageReader<MultiValueMap<String, Part>>
Class Inheritance
All Implemented Interfaces
org.springframework.http.codec.HttpMessageReader
Imports
java.util.ArrayList, .Collection, .List, .Map, java.util.stream.Collectors, reactor.core.publisher.Flux, .Mono, org.springframework.core.ResolvableType, org.springframework.core.codec.Hints, org.springframework.core.log.LogFormatUtils, org.springframework.http.MediaType, .ReactiveHttpInputMessage, org.springframework.http.codec.HttpMessageReader, .LoggingCodecSupport, org.springframework.lang.Nullable, org.springframework.util.Assert, .LinkedMultiValueMap, .MultiValueMap

HttpMessageReader for reading "multipart/form-data" requests into a MultiValueMap<String, Part>.

Note that this reader depends on access to an HttpMessageReader<Part> for the actual parsing of multipart content. The purpose of this reader is to collect the parts into a map.

Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
pack-priv static final List<MediaType>
private static final ResolvableType
private final HttpMessageReader<Part>
Inherited from org.springframework.http.codec.LoggingCodecSupport:
logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
canRead(ResolvableType
the type of object to check
elementType
,
MediaType
the media type for the read (possibly null)
mediaType
)

Implements org.springframework.http.codec.HttpMessageReader.canRead.

Whether the given object type is supported by this reader.
public HttpMessageReader<Part>
getPartReader()

Return the configured parts reader.

public List<MediaType>
getReadableMediaTypes()

Implements org.springframework.http.codec.HttpMessageReader.getReadableMediaTypes.

Return the list of media types supported by this reader.
public Flux<MultiValueMap<String, Part>>
read(ResolvableType
the type of objects in the stream which must have been previously checked via canRead(ResolvableType, MediaType)
elementType
,
ReactiveHttpInputMessage
the message to read from
message
,
Map<String, Object>
additional information about how to read and decode the input
hints
)

Implements org.springframework.http.codec.HttpMessageReader.read.

Read from the input message and decode to a stream of objects.
public Mono<MultiValueMap<String, Part>>
readMono(ResolvableType
the type of objects in the stream which must have been previously checked via canRead(ResolvableType, MediaType)
elementType
,
ReactiveHttpInputMessage
the message to read from
inputMessage
,
Map<String, Object>
additional information about how to read and decode the input
hints
)

Implements org.springframework.http.codec.HttpMessageReader.readMono.

Read from the input message and decode to a single object.
private boolean
private List<Part>
toList(Collection<Part> collection)

private LinkedMultiValueMap<String, Part>
Inherited from org.springframework.http.codec.LoggingCodecSupport:
isEnableLoggingRequestDetailssetEnableLoggingRequestDetails

Field Detail

MIME_TYPESback to summary
pack-priv static final List<MediaType> MIME_TYPES
MULTIPART_VALUE_TYPEback to summary
private static final ResolvableType MULTIPART_VALUE_TYPE
partReaderback to summary
private final HttpMessageReader<Part> partReader

Constructor Detail

MultipartHttpMessageReaderback to summary
public MultipartHttpMessageReader(HttpMessageReader<Part> partReader)

Method Detail

canReadback to summary
public boolean canRead(ResolvableType elementType, MediaType mediaType)

Implements org.springframework.http.codec.HttpMessageReader.canRead.

Doc from org.springframework.http.codec.HttpMessageReader.canRead.

Whether the given object type is supported by this reader.

Parameters
elementType:ResolvableType

the type of object to check

mediaType:MediaType

the media type for the read (possibly null)

Returns:boolean

true if readable, false otherwise

Annotations
@Override
getPartReaderback to summary
public HttpMessageReader<Part> getPartReader()

Return the configured parts reader.

Since
5.1.11
getReadableMediaTypesback to summary
public List<MediaType> getReadableMediaTypes()

Implements org.springframework.http.codec.HttpMessageReader.getReadableMediaTypes.

Doc from org.springframework.http.codec.HttpMessageReader.getReadableMediaTypes.

Return the list of media types supported by this reader. The list may not apply to every possible target element type and calls to this method should typically be guarded via canWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, use getReadableMediaTypes(ResolvableType) for a more precise list.

Returns:List<MediaType>

the general list of supported media types

Annotations
@Override
readback to summary
public Flux<MultiValueMap<String, Part>> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints)

Implements org.springframework.http.codec.HttpMessageReader.read.

Doc from org.springframework.http.codec.HttpMessageReader.read.

Read from the input message and decode to a stream of objects.

Parameters
elementType:ResolvableType

the type of objects in the stream which must have been previously checked via canRead(ResolvableType, MediaType)

message:ReactiveHttpInputMessage

the message to read from

hints:Map<String, Object>

additional information about how to read and decode the input

Returns:Flux<MultiValueMap<String, Part>>

the decoded stream of elements

Annotations
@Override
readMonoback to summary
public Mono<MultiValueMap<String, Part>> readMono(ResolvableType elementType, ReactiveHttpInputMessage inputMessage, Map<String, Object> hints)

Implements org.springframework.http.codec.HttpMessageReader.readMono.

Doc from org.springframework.http.codec.HttpMessageReader.readMono.

Read from the input message and decode to a single object.

Parameters
elementType:ResolvableType

the type of objects in the stream which must have been previously checked via canRead(ResolvableType, MediaType)

inputMessage:ReactiveHttpInputMessage

the message to read from

hints:Map<String, Object>

additional information about how to read and decode the input

Returns:Mono<MultiValueMap<String, Part>>

the decoded object

Annotations
@Override
supportsMediaTypeback to summary
private boolean supportsMediaType(MediaType mediaType)
toListback to summary
private List<Part> toList(Collection<Part> collection)
toMultiValueMapback to summary
private LinkedMultiValueMap<String, Part> toMultiValueMap(Map<String, Collection<Part>> map)