类 MultipartHttpMessageWriter
java.lang.Object
cn.taketoday.http.codec.LoggingCodecSupport
cn.taketoday.http.codec.multipart.MultipartWriterSupport
cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter
- 所有已实现的接口:
HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,?>>
public class MultipartHttpMessageWriter
extends MultipartWriterSupport
implements HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,?>>
HttpMessageWriter for writing a MultiValueMap<String, ?>
as multipart form data, i.e. "multipart/form-data", to the body
of a request.
The serialization of individual parts is delegated to other writers.
By default only String and Resource parts are supported but
you can configure others through a constructor argument.
This writer can be configured with a FormHttpMessageWriter to
delegate to. It is the preferred way of supporting both form data and
multipart data (as opposed to registering each writer separately) so that
when the MediaType is not specified and generics are not present on
the target element type, we can inspect the values in the actual map and
decide whether to write plain form data (String values only) or otherwise.
- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze, Rossen Stoyanchev
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明Suppress logging from individual part writers (full map logged at this level).private final HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>> private final Supplier<List<HttpMessageWriter<?>>>从类继承的字段 cn.taketoday.http.codec.multipart.MultipartWriterSupport
DEFAULT_CHARSET从类继承的字段 cn.taketoday.http.codec.LoggingCodecSupport
logger -
构造器概要
构造器构造器说明Constructor with a default list of part writers (String and Resource).MultipartHttpMessageWriter(Supplier<List<HttpMessageWriter<?>>> partWritersSupplier, HttpMessageWriter<cn.taketoday.util.MultiValueMap<String, String>> formWriter) Constructor with a supplier for an explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only.MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters) Constructor with explicit list of writers for serializing parts.MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters, HttpMessageWriter<cn.taketoday.util.MultiValueMap<String, String>> formWriter) Constructor with explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only. -
方法概要
修饰符和类型方法说明booleanWhether the given object type is supported by this writer.private <T> reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>encodePart(byte[] boundary, String name, T value, cn.taketoday.core.io.buffer.DataBufferFactory factory) private reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>encodePartValues(byte[] boundary, String name, List<?> values, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory) HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>> Return the configured form writer.Return the configured part writers.initMediaTypes(HttpMessageWriter<?> formWriter) private booleanisMultipart(cn.taketoday.util.MultiValueMap<String, ?> map, MediaType contentType) reactor.core.publisher.Mono<Void>write(org.reactivestreams.Publisher<? extends cn.taketoday.util.MultiValueMap<String, ?>> inputStream, cn.taketoday.core.ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String, Object> hints) Write an given stream of object to the output message.private reactor.core.publisher.Mono<Void>writeMultipart(cn.taketoday.util.MultiValueMap<String, ?> map, ReactiveHttpOutputMessage outputMessage, MediaType mediaType, Map<String, Object> hints) 从类继承的方法 cn.taketoday.http.codec.multipart.MultipartWriterSupport
generateBoundaryLine, generateLastLine, generateMultipartBoundary, generateNewLine, generatePartHeaders, getCharset, getMultipartMediaType, getWritableMediaTypes, setCharset从类继承的方法 cn.taketoday.http.codec.LoggingCodecSupport
isEnableLoggingRequestDetails, setEnableLoggingRequestDetails从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.http.codec.HttpMessageWriter
getWritableMediaTypes, getWritableMediaTypes, write
-
字段详细资料
-
DEFAULT_HINTS
Suppress logging from individual part writers (full map logged at this level). -
partWritersSupplier
-
formWriter
@Nullable private final HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,String>> formWriter
-
-
构造器详细资料
-
MultipartHttpMessageWriter
public MultipartHttpMessageWriter()Constructor with a default list of part writers (String and Resource). -
MultipartHttpMessageWriter
Constructor with explicit list of writers for serializing parts. -
MultipartHttpMessageWriter
public MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters, @Nullable HttpMessageWriter<cn.taketoday.util.MultiValueMap<String, String>> formWriter) Constructor with explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only.- 参数:
partWriters- the writers for serializing partsformWriter- the fallback writer for form data,nullby default
-
MultipartHttpMessageWriter
public MultipartHttpMessageWriter(Supplier<List<HttpMessageWriter<?>>> partWritersSupplier, @Nullable HttpMessageWriter<cn.taketoday.util.MultiValueMap<String, String>> formWriter) Constructor with a supplier for an explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only.- 参数:
partWritersSupplier- the supplier for writers for serializing partsformWriter- the fallback writer for form data,nullby default
-
-
方法详细资料
-
initMediaTypes
-
getPartWriters
Return the configured part writers.- 从以下版本开始:
- 4.0
-
getFormWriter
Return the configured form writer. -
canWrite
public boolean canWrite(cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType) 从接口复制的说明:HttpMessageWriterWhether the given object type is supported by this writer.- 指定者:
canWrite在接口中HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,?>> - 参数:
elementType- the type of object to checkmediaType- the media type for the write (possiblynull)- 返回:
trueif writable,falseotherwise
-
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends cn.taketoday.util.MultiValueMap<String, ?>> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String, Object> hints) 从接口复制的说明:HttpMessageWriterWrite an given stream of object to the output message.- 指定者:
write在接口中HttpMessageWriter<cn.taketoday.util.MultiValueMap<String,?>> - 参数:
inputStream- the objects to writeelementType- the type of objects in the stream which must have been previously checked viaHttpMessageWriter.canWrite(ResolvableType, MediaType)mediaType- the content type for the write (possiblynullto indicate that the default content type of the writer must be used)outputMessage- the message to write tohints- additional information about how to encode and write- 返回:
- indicates completion or error
-
isMultipart
-
writeMultipart
-
encodePartValues
-
encodePart
private <T> reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> encodePart(byte[] boundary, String name, T value, cn.taketoday.core.io.buffer.DataBufferFactory factory)
-