Class CompletedPart

java.lang.Object
io.micronaut.http.multipart.CompletedPart
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
CompletedAttribute, CompletedFileUpload

public abstract sealed class CompletedPart extends Object implements Closeable permits CompletedAttribute, CompletedFileUpload
Represents a completed part of a multipart request.
Since:
1.3.0
Author:
James Kleeh
  • Method Details

    • getMetadata

      public final FormFieldMetadata getMetadata()
      Get the metadata for this field.
      Returns:
      The metadata
    • getName

      public final String getName()
      Get the form field name.
      Returns:
      The field name
      See Also:
    • isInMemory

      public abstract boolean isInMemory()
    • closeAsync

      public abstract void closeAsync(Executor ioExecutor)
      Closeable.close() may be a blocking operation. This method closes this part asynchronously instead, on the given executor, if a blocking operation needs to be performed.
      Parameters:
      ioExecutor - The executor
    • getSize

      public abstract long getSize()
      Get the definite size in bytes of the form field value. Remains accessible after this part is closed.
      Returns:
      The size in bytes
    • getInputStream

      public abstract InputStream getInputStream() throws IOException
      Open a new InputStream that reads this form field. The returned stream must be closed. You must still close this CompletedPart also.

      This is a blocking operation.

      Returns:
      A stream
      Throws:
      IOException
    • toReadBuffer

      public abstract ReadBuffer toReadBuffer() throws IOException
      Read all data of this form field into memory. The returned buffer must be closed after use. You must still close this CompletedPart also.

      This is a blocking operation.

      This operation has no size limit. If the uploaded file is large, calling this method may use a lot of memory.

      Returns:
      The buffered value
      Throws:
      IOException
    • getBytes

      public final byte[] getBytes() throws IOException
      Read all data of this form field into memory. You must still close this CompletedPart.

      This is a blocking operation.

      This operation has no size limit. If the uploaded file is large, calling this method may use a lot of memory.

      Returns:
      The buffered value
      Throws:
      IOException
    • moveResource

      public abstract CompletedPart moveResource()
      The completed part objects passed to a controller are closed when the associated request ends. If you want to keep them around for longer, you can use this method to create a new CompletedPart with the same data. You are responsible for closing the new part.
      Returns:
      A new completed part