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

public Class MultipartWriterSupport

extends LoggingCodecSupport
Class Inheritance
Known Direct Subclasses
org.springframework.http.codec.multipart.PartEventHttpMessageWriter, org.springframework.http.codec.multipart.PartHttpMessageWriter, org.springframework.http.codec.multipart.MultipartHttpMessageWriter
Imports
java.nio.charset.Charset, .StandardCharsets, java.util.HashMap, .List, .Map, reactor.core.publisher.Mono, org.springframework.core.io.buffer.DataBuffer, .DataBufferFactory, org.springframework.http.HttpHeaders, .MediaType, org.springframework.http.codec.LoggingCodecSupport, org.springframework.lang.Nullable, org.springframework.util.Assert, .FastByteArrayOutputStream, .MimeTypeUtils

Support class for multipart HTTP message writers.
Author
Rossen Stoyanchev
Since
5.3

Field Summary

Modifier and TypeField and Description
private Charset
public static final Charset
DEFAULT_CHARSET

THe default charset used by the writer.

private final List<MediaType>
Inherited from org.springframework.http.codec.LoggingCodecSupport:
logger

Constructor Summary

AccessConstructor and Description
protected
MultipartWriterSupport(List<MediaType> supportedMediaTypes)

Constructor with the list of supported media types.

Method Summary

Modifier and TypeMethod and Description
protected Mono<DataBuffer>
generateBoundaryLine(byte[] boundary, DataBufferFactory bufferFactory)

protected Mono<DataBuffer>
generateLastLine(byte[] boundary, DataBufferFactory bufferFactory)

protected byte[]
generateMultipartBoundary()

Generate a multipart boundary.

protected Mono<DataBuffer>
protected Mono<DataBuffer>
public Charset
getCharset()

Return the configured charset for part headers.

protected MediaType
getMultipartMediaType(MediaType mediaType, byte[] boundary)

Prepare the MediaType to use by adding "boundary" and "charset" parameters to the given mediaType or "multipart/form-data" otherwise by default.

public List<MediaType>
public void
setCharset(Charset charset)

Set the character set to use for part headers such as "Content-Disposition" (and its filename parameter).

Inherited from org.springframework.http.codec.LoggingCodecSupport:
isEnableLoggingRequestDetailssetEnableLoggingRequestDetails

Field Detail

charsetback to summary
private Charset charset
DEFAULT_CHARSETback to summary
public static final Charset DEFAULT_CHARSET

THe default charset used by the writer.

supportedMediaTypesback to summary
private final List<MediaType> supportedMediaTypes

Constructor Detail

MultipartWriterSupportback to summary
protected MultipartWriterSupport(List<MediaType> supportedMediaTypes)

Constructor with the list of supported media types.

Method Detail

generateBoundaryLineback to summary
protected Mono<DataBuffer> generateBoundaryLine(byte[] boundary, DataBufferFactory bufferFactory)
generateLastLineback to summary
protected Mono<DataBuffer> generateLastLine(byte[] boundary, DataBufferFactory bufferFactory)
generateMultipartBoundaryback to summary
protected byte[] generateMultipartBoundary()

Generate a multipart boundary.

By default delegates to MimeTypeUtils#generateMultipartBoundary().

generateNewLineback to summary
protected Mono<DataBuffer> generateNewLine(DataBufferFactory bufferFactory)
generatePartHeadersback to summary
protected Mono<DataBuffer> generatePartHeaders(HttpHeaders headers, DataBufferFactory bufferFactory)
getCharsetback to summary
public Charset getCharset()

Return the configured charset for part headers.

getMultipartMediaTypeback to summary
protected MediaType getMultipartMediaType(MediaType mediaType, byte[] boundary)

Prepare the MediaType to use by adding "boundary" and "charset" parameters to the given mediaType or "multipart/form-data" otherwise by default.

getWritableMediaTypesback to summary
public List<MediaType> getWritableMediaTypes()
setCharsetback to summary
public void setCharset(Charset charset)

Set the character set to use for part headers such as "Content-Disposition" (and its filename parameter).

By default this is set to "UTF-8". If changed from this default, the "Content-Type" header will have a "charset" parameter that specifies the character set used.