Class NettyCompletedFileUpload
java.lang.Object
io.micronaut.http.server.netty.multipart.NettyCompletedFileUpload
- All Implemented Interfaces:
CompletedFileUpload
,CompletedPart
,FileUpload
,PartData
A Netty implementation of
CompletedFileUpload
.- Since:
- 1.0.0
- Author:
- Zachary Klein
-
Constructor Summary
ConstructorDescriptionNettyCompletedFileUpload
(io.netty.handler.codec.http.multipart.FileUpload fileUpload) NettyCompletedFileUpload
(io.netty.handler.codec.http.multipart.FileUpload fileUpload, boolean controlRelease) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
discard()
Discards the contents of the file.Gets the content of this part as aByteBuffer
.byte[]
getBytes()
Gets the content of this part as abyte[]
.Gets the content type of this part.long
Returns the defined content length of the part.Gets the name of this part.Gets the content of this part as aInputStream
.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.
-
Constructor Details
-
NettyCompletedFileUpload
public NettyCompletedFileUpload(io.netty.handler.codec.http.multipart.FileUpload fileUpload) - Parameters:
fileUpload
- The file upload
-
NettyCompletedFileUpload
public NettyCompletedFileUpload(io.netty.handler.codec.http.multipart.FileUpload fileUpload, boolean controlRelease) - Parameters:
fileUpload
- The file uploadcontrolRelease
- If true, release after retrieving the data
-
-
Method Details
-
getInputStream
Gets the content of this part as aInputStream
.The contents of the file will be released when the stream is closed. This method should only be called once
- Specified by:
getInputStream
in interfacePartData
- Returns:
- The content of this part as a
InputStream
- Throws:
IOException
- If an error occurs in retrieving the content
-
getBytes
Gets the content of this part as abyte[]
.Because the contents of the file are released after being retrieved, this method can only be called once
- Specified by:
getBytes
in interfacePartData
- Returns:
- The content of this part as a
byte[]
- Throws:
IOException
- If an error occurs in retrieving the content
-
getByteBuffer
Gets the content of this part as aByteBuffer
.Because the contents of the file are released after being retrieved, this method can only be called once
- Specified by:
getByteBuffer
in interfacePartData
- Returns:
- The content of this part as a
ByteBuffer
- Throws:
IOException
- If an error occurs in retrieving the content
-
getContentType
Description copied from interface:FileUpload
Gets the content type of this part.- Specified by:
getContentType
in interfaceFileUpload
- Specified by:
getContentType
in interfacePartData
- Returns:
- The content type of this part.
-
getName
Description copied from interface:FileUpload
Gets the name of this part.- Specified by:
getName
in interfaceCompletedPart
- 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
-
discard
public final 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
-