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

pack-priv abstract Class DefaultParts

extends Object
Class Inheritance
Imports
java.nio.file.Files, .Path, .StandardCopyOption, .StandardOpenOption, java.util.concurrent.Callable, reactor.core.publisher.Flux, .Mono, reactor.core.scheduler.Scheduler, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, .DefaultDataBufferFactory, org.springframework.http.ContentDisposition, .HttpHeaders, org.springframework.util.Assert

Default implementations of Part and subtypes.
Author
Arjen Poutsma
Since
5.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
DefaultParts.AbstractPart

Abstract base class for Part implementations.

private static interface
DefaultParts.Content

Part content abstraction.

private static class
DefaultParts.DefaultFilePart

Default implementation of FilePart.

private static class
private static class
DefaultParts.DefaultPart

Default implementation of Part.

private static class
DefaultParts.FileContent

Content implementation based on a file.

private static class
DefaultParts.FluxContent

Content implementation based on a flux of data buffers.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static FormFieldPart

Returns:

the created part
formFieldPart
(HttpHeaders
the part headers
headers
,
String
the form field value
value
)

Create a new FormFieldPart with the given parameters.

public static Part
part(HttpHeaders
the part headers
headers
,
Flux<DataBuffer>
the content of the part
dataBuffers
)

Create a new Part or FilePart based on a flux of data buffers.

public static Part
part(HttpHeaders
the part headers
headers
,
Path
the file
file
,
Scheduler
the scheduler used for reading the file
scheduler
)

Create a new Part or FilePart based on the given file.

private static Part
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultPartsback to summary
pack-priv DefaultParts()

Method Detail

formFieldPartback to summary
public static FormFieldPart formFieldPart(HttpHeaders headers, String value)

Create a new FormFieldPart with the given parameters.

Parameters
headers:HttpHeaders

the part headers

value:String

the form field value

Returns:FormFieldPart

the created part

partback to summary
public static Part part(HttpHeaders headers, Flux<DataBuffer> dataBuffers)

Create a new Part or FilePart based on a flux of data buffers. Returns FilePart if the Content-Disposition of the given headers contains a filename, or a "normal" Part otherwise.

Parameters
headers:HttpHeaders

the part headers

dataBuffers:Flux<DataBuffer>

the content of the part

Returns:Part

Part or FilePart, depending on HttpHeaders#getContentDisposition()

partback to summary
public static Part part(HttpHeaders headers, Path file, Scheduler scheduler)

Create a new Part or FilePart based on the given file. Returns FilePart if the Content-Disposition of the given headers contains a filename, or a "normal" Part otherwise

Parameters
headers:HttpHeaders

the part headers

file:Path

the file

scheduler:Scheduler

the scheduler used for reading the file

Returns:Part

Part or FilePart, depending on HttpHeaders#getContentDisposition()

partInternalback to summary
private static Part partInternal(HttpHeaders headers, DefaultParts.Content content)
org.springframework.http.codec.multipart back to summary

private abstract Class DefaultParts.AbstractPart

extends Object
implements Part
Class Inheritance
  • java.lang.Object
  • org.springframework.http.codec.multipart.DefaultParts.AbstractPart
All Implemented Interfaces
org.springframework.http.codec.multipart.Part
Known Direct Subclasses
org.springframework.http.codec.multipart.DefaultParts.DefaultFormFieldPart, org.springframework.http.codec.multipart.DefaultParts.DefaultPart

Abstract base class for Part implementations.

Field Summary

Modifier and TypeField and Description
private final HttpHeaders

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public HttpHeaders
headers()

Implements org.springframework.http.codec.multipart.Part.headers.

Return the headers associated with the part.

public String
name()

Implements org.springframework.http.codec.multipart.Part.name.

Return the name of the part in the multipart form.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersback to summary
private final HttpHeaders headers

Constructor Detail

AbstractPartback to summary
protected AbstractPart(HttpHeaders headers)

Method Detail

headersback to summary
public HttpHeaders headers()

Implements org.springframework.http.codec.multipart.Part.headers.

Doc from org.springframework.http.codec.multipart.Part.headers.

Return the headers associated with the part.

Annotations
@Override
nameback to summary
public String name()

Implements org.springframework.http.codec.multipart.Part.name.

Doc from org.springframework.http.codec.multipart.Part.name.

Return the name of the part in the multipart form.

Returns:String

the name of the part, never null or empty

Annotations
@Override
org.springframework.http.codec.multipart back to summary

private Interface DefaultParts.Content

Known Direct Implementers
org.springframework.http.codec.multipart.DefaultParts.FluxContent, org.springframework.http.codec.multipart.DefaultParts.FileContent

Part content abstraction.

Method Summary

Modifier and TypeMethod and Description
public Flux<DataBuffer>
public Mono<Void>
public Mono<Void>

Method Detail

contentback to summary
public Flux<DataBuffer> content()
deleteback to summary
public Mono<Void> delete()
transferToback to summary
public Mono<Void> transferTo(Path dest)
org.springframework.http.codec.multipart back to summary

private final Class DefaultParts.DefaultFilePart

extends DefaultPart
implements FilePart
Class Inheritance
All Implemented Interfaces
org.springframework.http.codec.multipart.FilePart, org.springframework.http.codec.multipart.Part

Default implementation of FilePart.

Field Summary

Inherited from org.springframework.http.codec.multipart.DefaultParts.DefaultPart:
content

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
filename()

Implements org.springframework.http.codec.multipart.FilePart.filename.

Return the original filename in the client's filesystem.

public String
toString()

Overrides org.springframework.http.codec.multipart.DefaultParts.DefaultPart.toString.

Returns a string representation of the object.

public Mono<Void>
transferTo(Path
the target file
dest
)

Implements org.springframework.http.codec.multipart.FilePart.transferTo.

Convenience method to copy the content of the file in this part to the given destination file.

Inherited from org.springframework.http.codec.multipart.DefaultParts.DefaultPart:
contentdelete

Constructor Detail

DefaultFilePartback to summary
public DefaultFilePart(HttpHeaders headers, DefaultParts.Content content)

Method Detail

filenameback to summary
public String filename()

Implements org.springframework.http.codec.multipart.FilePart.filename.

Doc from org.springframework.http.codec.multipart.FilePart.filename.

Return the original filename in the client's filesystem.

Note

Please keep in mind this filename is supplied by the client and should not be used blindly. In addition to not using the directory portion, the file name could also contain characters such as ".." and others that can be used maliciously. It is recommended to not use this filename directly. Preferably generate a unique one and save this one somewhere for reference, if necessary.

Returns:String

the original filename, or the empty String if no file has been chosen in the multipart form, or null if not defined or not available

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.springframework.http.codec.multipart.DefaultParts.DefaultPart.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
transferToback to summary
public Mono<Void> transferTo(Path dest)

Implements org.springframework.http.codec.multipart.FilePart.transferTo.

Doc from org.springframework.http.codec.multipart.FilePart.transferTo.

Convenience method to copy the content of the file in this part to the given destination file. If the destination file already exists, it will be truncated first.

Parameters
dest:Path

the target file

Returns:Mono<Void>

completion Mono with the result of the file transfer, possibly IllegalStateException if the part isn't a file

Annotations
@Override
org.springframework.http.codec.multipart back to summary

private Class DefaultParts.DefaultFormFieldPart

extends AbstractPart
implements FormFieldPart
Class Inheritance
All Implemented Interfaces
org.springframework.http.codec.multipart.FormFieldPart, org.springframework.http.codec.multipart.Part

Default implementation of FormFieldPart.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Flux<DataBuffer>
content()

Implements org.springframework.http.codec.multipart.Part.content.

Return the content for this part.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public String
value()

Implements org.springframework.http.codec.multipart.FormFieldPart.value.

Return the form field value.

Inherited from org.springframework.http.codec.multipart.DefaultParts.AbstractPart:
headersname

Field Detail

valueback to summary
private final String value

Constructor Detail

DefaultFormFieldPartback to summary
public DefaultFormFieldPart(HttpHeaders headers, String value)

Method Detail

contentback to summary
public Flux<DataBuffer> content()

Implements org.springframework.http.codec.multipart.Part.content.

Doc from org.springframework.http.codec.multipart.Part.content.

Return the content for this part.

Note that for a FormFieldPart the content may be accessed more easily via FormFieldPart#value().

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
valueback to summary
public String value()

Implements org.springframework.http.codec.multipart.FormFieldPart.value.

Doc from org.springframework.http.codec.multipart.FormFieldPart.value.

Return the form field value.

Annotations
@Override
org.springframework.http.codec.multipart back to summary

private Class DefaultParts.DefaultPart

extends AbstractPart
Class Inheritance
Known Direct Subclasses
org.springframework.http.codec.multipart.DefaultParts.DefaultFilePart

Default implementation of Part.

Field Summary

Modifier and TypeField and Description
protected final DefaultParts.Content

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Flux<DataBuffer>
content()

Implements org.springframework.http.codec.multipart.Part.content.

Return the content for this part.

public Mono<Void>
delete()

Overrides default org.springframework.http.codec.multipart.Part.delete.

Return a mono that, when subscribed to, deletes the underlying storage for this part.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.springframework.http.codec.multipart.DefaultParts.AbstractPart:
headersname

Field Detail

contentback to summary
protected final DefaultParts.Content content

Constructor Detail

DefaultPartback to summary
public DefaultPart(HttpHeaders headers, DefaultParts.Content content)

Method Detail

contentback to summary
public Flux<DataBuffer> content()

Implements org.springframework.http.codec.multipart.Part.content.

Doc from org.springframework.http.codec.multipart.Part.content.

Return the content for this part.

Note that for a FormFieldPart the content may be accessed more easily via FormFieldPart#value().

Annotations
@Override
deleteback to summary
public Mono<Void> delete()

Overrides default org.springframework.http.codec.multipart.Part.delete.

Doc from org.springframework.http.codec.multipart.Part.delete.

Return a mono that, when subscribed to, deletes the underlying storage for this part.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.springframework.http.codec.multipart back to summary

private final Class DefaultParts.FileContent

extends Object
implements Content
Class Inheritance
  • java.lang.Object
  • org.springframework.http.codec.multipart.DefaultParts.FileContent
All Implemented Interfaces
org.springframework.http.codec.multipart.DefaultParts.Content

Content implementation based on a file.

Field Summary

Modifier and TypeField and Description
private final Path
private final Scheduler

Constructor Summary

AccessConstructor and Description
public
FileContent(Path file, Scheduler scheduler)

Method Summary

Modifier and TypeMethod and Description
private Mono<Void>
public Flux<DataBuffer>
public Mono<Void>
public Mono<Void>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileback to summary
private final Path file
schedulerback to summary
private final Scheduler scheduler

Constructor Detail

FileContentback to summary
public FileContent(Path file, Scheduler scheduler)

Method Detail

blockingOperationback to summary
private Mono<Void> blockingOperation(Callable<?> callable)
contentback to summary
public Flux<DataBuffer> content()

Implements org.springframework.http.codec.multipart.DefaultParts.Content.content.

Annotations
@Override
deleteback to summary
public Mono<Void> delete()

Implements org.springframework.http.codec.multipart.DefaultParts.Content.delete.

Annotations
@Override
transferToback to summary
public Mono<Void> transferTo(Path dest)

Implements org.springframework.http.codec.multipart.DefaultParts.Content.transferTo.

Annotations
@Override
org.springframework.http.codec.multipart back to summary

private final Class DefaultParts.FluxContent

extends Object
implements Content
Class Inheritance
  • java.lang.Object
  • org.springframework.http.codec.multipart.DefaultParts.FluxContent
All Implemented Interfaces
org.springframework.http.codec.multipart.DefaultParts.Content

Content implementation based on a flux of data buffers.

Field Summary

Modifier and TypeField and Description
private final Flux<DataBuffer>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Flux<DataBuffer>
public Mono<Void>
public Mono<Void>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentback to summary
private final Flux<DataBuffer> content

Constructor Detail

FluxContentback to summary
public FluxContent(Flux<DataBuffer> content)

Method Detail

contentback to summary
public Flux<DataBuffer> content()

Implements org.springframework.http.codec.multipart.DefaultParts.Content.content.

Annotations
@Override
deleteback to summary
public Mono<Void> delete()

Implements org.springframework.http.codec.multipart.DefaultParts.Content.delete.

Annotations
@Override
transferToback to summary
public Mono<Void> transferTo(Path dest)

Implements org.springframework.http.codec.multipart.DefaultParts.Content.transferTo.

Annotations
@Override