Class NettyStreamingFileUpload
java.lang.Object
io.micronaut.http.server.netty.multipart.NettyStreamingFileUpload
- All Implemented Interfaces:
FileUpload
,StreamingFileUpload
,Publisher<PartData>
An implementation of the
StreamingFileUpload
interface for Netty.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Factory for instances ofNettyStreamingFileUpload
. -
Method Summary
Modifier and TypeMethodDescriptionprotected File
createTemp
(String location) delete()
Deletes the underlying storage for a file item, including deleting any associated temporary disk file.void
discard()
Discards the contents of the file.Gets the content type of this part.long
Returns the defined content length of the part.Gets the name of this part.getName()
Gets the name of this part.long
getSize()
Returns the size of the part.boolean
Returns whether theFileUpload
has been fully uploaded or is in a partial state.void
subscribe
(Subscriber<? super PartData> s) transferTo
(File destination) A convenience method to write this uploaded item to disk.transferTo
(OutputStream outputStream) A convenience method to write this uploaded item the provided output stream.transferTo
(String location) A convenience method to write this uploaded item to disk.
-
Method Details
-
getContentType
Description copied from interface:FileUpload
Gets the content type of this part.- Specified by:
getContentType
in interfaceFileUpload
- Returns:
- The content type of this part.
-
getName
Description copied from interface:FileUpload
Gets the name of this part.- Specified by:
getName
in interfaceFileUpload
- Returns:
- The name of this part
-
getFilename
Description copied from interface:FileUpload
Gets the name of this part.- Specified by:
getFilename
in interfaceFileUpload
- Returns:
- The name of this part
-
getSize
public long getSize()Description copied from interface:FileUpload
Returns the size of the part.- Specified by:
getSize
in interfaceFileUpload
- Returns:
- The size of this part, in bytes.
-
getDefinedSize
public long getDefinedSize()Description copied from interface:FileUpload
Returns the defined content length of the part.- Specified by:
getDefinedSize
in interfaceFileUpload
- Returns:
- The content length of this part, in bytes.
-
isComplete
public boolean isComplete()Description copied from interface:FileUpload
Returns whether theFileUpload
has been fully uploaded or is in a partial state.- Specified by:
isComplete
in interfaceFileUpload
- Returns:
- True if the part is fully uploaded
-
transferTo
Description copied from interface:StreamingFileUpload
A convenience method to write this uploaded item to disk.
This method will return a no-op
Publisher
if called multiple times for the same location- Specified by:
transferTo
in interfaceStreamingFileUpload
- Parameters:
location
- the name of the file to which the stream will be written. The file is created relative to the location as specified in theMultipartConfiguration
- Returns:
- A
Publisher
that outputs whether the transfer was successful
-
transferTo
Description copied from interface:StreamingFileUpload
A convenience method to write this uploaded item to disk.
This method will return a no-op
Publisher
if called multiple times for the same location- Specified by:
transferTo
in interfaceStreamingFileUpload
- Parameters:
destination
- the destination of the file to which the stream will be written.- Returns:
- A
Publisher
that outputs whether the transfer was successful
-
transferTo
Description copied from interface:StreamingFileUpload
A convenience method to write this uploaded item the provided output stream.
- Specified by:
transferTo
in interfaceStreamingFileUpload
- Parameters:
outputStream
- the destination to which the stream will be written.- Returns:
- A
Publisher
that outputs whether the transfer was successful
-
delete
Description copied from interface:StreamingFileUpload
Deletes the underlying storage for a file item, including deleting any associated temporary disk file.- Specified by:
delete
in interfaceStreamingFileUpload
- Returns:
- A
Publisher
that outputs whether the delete was successful
-
createTemp
- Parameters:
location
- The location for the temp file- Returns:
- The temporal file
-
subscribe
-
discard
public void discard()Description copied from interface:FileUpload
Discards the contents of the file. This must be called if the file will not be read and has not already been read. Failure to either read or discard the file will result in memory leaks!- Specified by:
discard
in interfaceFileUpload
-