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

public Interface FilePartEvent

extends PartEvent
Known Direct Implementers
org.springframework.http.codec.multipart.DefaultPartEvents.DefaultFilePartEvent
Imports
java.io.IOException, java.nio.charset.StandardCharsets, java.nio.file.Path, java.util.function.Consumer, reactor.core.publisher.Flux, .Mono, org.springframework.core.io.Resource, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, .DefaultDataBufferFactory, org.springframework.http.ContentDisposition, .HttpHeaders, .MediaType, .MediaTypeFactory, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

Represents an event triggered for a file upload. Contains the filename, besides the headers and content exposed through PartEvent.

On the client side, instances of this interface can be created via one of the overloaded create methods.

On the server side, multipart file uploads trigger one or more FilePartEvent, as described here.

Author
Arjen Poutsma
Since
6.0
See Also
PartEvent

Method Summary

Modifier and TypeMethod and Description
public static Flux<FilePartEvent>

Returns:

a stream of events
create
(String
the name of the part
name
,
Resource
the resource
resource
)

Creates a stream of FilePartEvent objects based on the given name and resource.

public static Flux<FilePartEvent>

Returns:

a stream of events
create
(String
the name of the part
name
,
Resource
the resource
resource
,
Consumer<HttpHeaders>
used to change default headers. Can be null.
headersConsumer
)

Creates a stream of FilePartEvent objects based on the given name and resource.

public static Flux<FilePartEvent>

Returns:

a stream of events
create
(String
the name of the part
name
,
Path
the file path
path
)

Creates a stream of FilePartEvent objects based on the given name and file path.

public static Flux<FilePartEvent>

Returns:

a stream of events
create
(String
the name of the part
name
,
Path
the file path
path
,
Consumer<HttpHeaders>
used to change default headers. Can be null.
headersConsumer
)

Creates a stream of FilePartEvent objects based on the given name and file path.

public static Flux<FilePartEvent>

Returns:

a stream of events
create
(String
the name of the part
partName
,
String
the filename
filename
,
MediaType
the content-type for the contents
contentType
,
Flux<DataBuffer>
the contents
contents
)

Creates a stream of FilePartEvent objects based on the given name, filename(), content-type, and contents.

public static Flux<FilePartEvent>

Returns:

a stream of events
create
(String
the name of the part
partName
,
String
the filename
filename
,
MediaType
the content-type for the contents
contentType
,
Flux<DataBuffer>
the contents
contents
,
Consumer<HttpHeaders>
used to change default headers. Can be null.
headersConsumer
)

Creates a stream of FilePartEvent objects based on the given name, filename(), content-type, and contents.

public default String

Returns:

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
filename
()

Return the original filename in the client's filesystem.

Inherited from org.springframework.http.codec.multipart.PartEvent:
contentheadersisLastname

Method Detail

createback to summary
public static Flux<FilePartEvent> create(String name, Resource resource)

Creates a stream of FilePartEvent objects based on the given name and resource.

Parameters
name:String

the name of the part

resource:Resource

the resource

Returns:Flux<FilePartEvent>

a stream of events

createback to summary
public static Flux<FilePartEvent> create(String name, Resource resource, Consumer<HttpHeaders> headersConsumer)

Creates a stream of FilePartEvent objects based on the given name and resource.

Parameters
name:String

the name of the part

resource:Resource

the resource

headersConsumer:Consumer<HttpHeaders>

used to change default headers. Can be null.

Returns:Flux<FilePartEvent>

a stream of events

createback to summary
public static Flux<FilePartEvent> create(String name, Path path)

Creates a stream of FilePartEvent objects based on the given name and file path.

Parameters
name:String

the name of the part

path:Path

the file path

Returns:Flux<FilePartEvent>

a stream of events

createback to summary
public static Flux<FilePartEvent> create(String name, Path path, Consumer<HttpHeaders> headersConsumer)

Creates a stream of FilePartEvent objects based on the given name and file path.

Parameters
name:String

the name of the part

path:Path

the file path

headersConsumer:Consumer<HttpHeaders>

used to change default headers. Can be null.

Returns:Flux<FilePartEvent>

a stream of events

createback to summary
public static Flux<FilePartEvent> create(String partName, String filename, MediaType contentType, Flux<DataBuffer> contents)

Creates a stream of FilePartEvent objects based on the given name, filename(), content-type, and contents.

Parameters
partName:String

the name of the part

filename:String

the filename

contentType:MediaType

the content-type for the contents

contents:Flux<DataBuffer>

the contents

Returns:Flux<FilePartEvent>

a stream of events

createback to summary
public static Flux<FilePartEvent> create(String partName, String filename, MediaType contentType, Flux<DataBuffer> contents, Consumer<HttpHeaders> headersConsumer)

Creates a stream of FilePartEvent objects based on the given name, filename(), content-type, and contents.

Parameters
partName:String

the name of the part

filename:String

the filename

contentType:MediaType

the content-type for the contents

contents:Flux<DataBuffer>

the contents

headersConsumer:Consumer<HttpHeaders>

used to change default headers. Can be null.

Returns:Flux<FilePartEvent>

a stream of events

filenameback to summary
public default String 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

See Also
RFC 7578, Section 4.2, Unrestricted File Upload