Class NettyCompletedFileUpload

java.lang.Object
io.micronaut.http.server.netty.multipart.NettyCompletedFileUpload
All Implemented Interfaces:
CompletedFileUpload, CompletedPart, FileUpload, PartData

@Internal public class NettyCompletedFileUpload extends Object implements CompletedFileUpload
A Netty implementation of CompletedFileUpload.
Since:
1.0.0
Author:
Zachary Klein
  • 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 upload
      controlRelease - If true, release after retrieving the data
  • Method Details

    • getInputStream

      public InputStream getInputStream() throws IOException
      Gets the content of this part as a InputStream.

      The contents of the file will be released when the stream is closed. This method should only be called once

      Specified by:
      getInputStream in interface PartData
      Returns:
      The content of this part as a InputStream
      Throws:
      IOException - If an error occurs in retrieving the content
    • getBytes

      public byte[] getBytes() throws IOException
      Gets the content of this part as a byte[].

      Because the contents of the file are released after being retrieved, this method can only be called once

      Specified by:
      getBytes in interface PartData
      Returns:
      The content of this part as a byte[]
      Throws:
      IOException - If an error occurs in retrieving the content
    • getByteBuffer

      public ByteBuffer getByteBuffer() throws IOException
      Gets the content of this part as a ByteBuffer.

      Because the contents of the file are released after being retrieved, this method can only be called once

      Specified by:
      getByteBuffer in interface PartData
      Returns:
      The content of this part as a ByteBuffer
      Throws:
      IOException - If an error occurs in retrieving the content
    • getContentType

      public Optional<MediaType> getContentType()
      Description copied from interface: FileUpload
      Gets the content type of this part.
      Specified by:
      getContentType in interface FileUpload
      Specified by:
      getContentType in interface PartData
      Returns:
      The content type of this part.
    • getName

      public String getName()
      Description copied from interface: FileUpload
      Gets the name of this part.
      Specified by:
      getName in interface CompletedPart
      Specified by:
      getName in interface FileUpload
      Returns:
      The name of this part
    • getFilename

      public String getFilename()
      Description copied from interface: FileUpload
      Gets the name of this part.
      Specified by:
      getFilename in interface FileUpload
      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 interface FileUpload
      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 interface FileUpload
      Returns:
      The content length of this part, in bytes.
    • isComplete

      public boolean isComplete()
      Description copied from interface: FileUpload
      Returns whether the FileUpload has been fully uploaded or is in a partial state.
      Specified by:
      isComplete in interface FileUpload
      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 interface FileUpload