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 Summary
Modifier and TypeMethodDescriptionabstract voidcloseAsync(Executor ioExecutor) Closeable.close()may be a blocking operation.final byte[]getBytes()Read all data of this form field into memory.abstract InputStreamOpen a newInputStreamthat reads this form field.final FormFieldMetadataGet the metadata for this field.final StringgetName()Get the form field name.abstract longgetSize()Get the definite size in bytes of the form field value.abstract booleanabstract CompletedPartThe completed part objects passed to a controller are closed when the associated request ends.abstract ReadBufferRead all data of this form field into memory.
-
Method Details
-
getMetadata
-
getName
-
isInMemory
public abstract boolean isInMemory() -
closeAsync
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
Open a newInputStreamthat reads this form field. The returned stream must be closed. You must still close thisCompletedPartalso.This is a blocking operation.
- Returns:
- A stream
- Throws:
IOException
-
toReadBuffer
Read all data of this form field into memory. The returned buffer must be closed after use. You must still close thisCompletedPartalso.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
Read all data of this form field into memory. You must still close thisCompletedPart.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
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 newCompletedPartwith the same data. You are responsible for closing the new part.- Returns:
- A new completed part
-