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
Nested ClassesModifier and TypeClassDescriptionstatic final recordFactory for instances ofNettyStreamingFileUpload. -
Method Summary
Modifier and TypeMethodDescriptionCreate anInputStreamthat reads this file.protected FilecreateTemp(String location) delete()Deletes the underlying storage for a file item, including deleting any associated temporary disk file.voiddiscard()Discards the contents of the file.Gets the content type of this part.longReturns the defined content length of the part.Gets the name of this part.getName()Gets the name of this part.longgetSize()Returns the size of the part.booleanReturns whether theFileUploadhas been fully uploaded or is in a partial state.voidsubscribe(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:FileUploadGets the content type of this part.- Specified by:
getContentTypein interfaceFileUpload- Returns:
- The content type of this part.
-
getName
Description copied from interface:FileUploadGets the name of this part.- Specified by:
getNamein interfaceFileUpload- Returns:
- The name of this part
-
getFilename
Description copied from interface:FileUploadGets the name of this part.- Specified by:
getFilenamein interfaceFileUpload- Returns:
- The name of this part
-
getSize
public long getSize()Description copied from interface:FileUploadReturns the size of the part.- Specified by:
getSizein interfaceFileUpload- Returns:
- The size of this part, in bytes.
-
getDefinedSize
public long getDefinedSize()Description copied from interface:FileUploadReturns the defined content length of the part.- Specified by:
getDefinedSizein interfaceFileUpload- Returns:
- The content length of this part, in bytes.
-
isComplete
public boolean isComplete()Description copied from interface:FileUploadReturns whether theFileUploadhas been fully uploaded or is in a partial state.- Specified by:
isCompletein interfaceFileUpload- Returns:
- True if the part is fully uploaded
-
transferTo
Description copied from interface:StreamingFileUploadA convenience method to write this uploaded item to disk.
This method will return a no-op
Publisherif called multiple times for the same location- Specified by:
transferToin 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
Publisherthat outputs whether the transfer was successful
-
transferTo
Description copied from interface:StreamingFileUploadA convenience method to write this uploaded item to disk.
This method will return a no-op
Publisherif called multiple times for the same location- Specified by:
transferToin interfaceStreamingFileUpload- Parameters:
destination- the destination of the file to which the stream will be written.- Returns:
- A
Publisherthat outputs whether the transfer was successful
-
transferTo
Description copied from interface:StreamingFileUploadA convenience method to write this uploaded item the provided output stream.
- Specified by:
transferToin interfaceStreamingFileUpload- Parameters:
outputStream- the destination to which the stream will be written.- Returns:
- A
Publisherthat outputs whether the transfer was successful
-
delete
Description copied from interface:StreamingFileUploadDeletes the underlying storage for a file item, including deleting any associated temporary disk file.- Specified by:
deletein interfaceStreamingFileUpload- Returns:
- A
Publisherthat outputs whether to delete was successful
-
asInputStream
Description copied from interface:StreamingFileUploadCreate anInputStreamthat reads this file. The returned stream must be closed after use. The stream may block when data isn't yet available.- Specified by:
asInputStreamin interfaceStreamingFileUpload- Returns:
- An
InputStreamthat reads this file's contents
-
createTemp
- Parameters:
location- The location for the temp file- Returns:
- The temporal file
-
subscribe
-
discard
public void discard()Description copied from interface:FileUploadDiscards 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:
discardin interfaceFileUpload
-