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

public Interface FilePart

extends Part
Known Direct Implementers
org.springframework.http.codec.multipart.DefaultParts.DefaultFilePart
Imports
java.io.File, java.nio.file.Path, reactor.core.publisher.Mono

Specialization of Part that represents an uploaded file received in a multipart request.
Authors
Rossen Stoyanchev, Juergen Hoeller
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public 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.

public default Mono<Void>

Returns:

completion Mono with the result of the file transfer, possibly IllegalStateException if the part isn't a file
transferTo
(File
the target file
dest
)

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

public Mono<Void>

Returns:

completion Mono with the result of the file transfer, possibly IllegalStateException if the part isn't a file
transferTo
(Path
the target file
dest
)

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

Inherited from org.springframework.http.codec.multipart.Part:
contentdeleteheadersname

Method Detail

filenameback to summary
public 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
transferToback to summary
public default Mono<Void> transferTo(File dest)

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.

The default implementation delegates to transferTo(Path).

Parameters
dest:File

the target file

Returns:Mono<Void>

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

See Also
transferTo(Path)
transferToback to summary
public Mono<Void> transferTo(Path dest)

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

Since
5.1
See Also
transferTo(File)