Class CompletedAttribute
java.lang.Object
io.micronaut.http.multipart.CompletedPart
io.micronaut.http.multipart.CompletedAttribute
- All Implemented Interfaces:
Closeable, AutoCloseable
A form field that is not a file upload.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcloseAsync(Executor ioExecutor) Closeable.close()may be a blocking operation.static CompletedAttributecreate(FormFieldMetadata metadata, ReadBuffer readBuffer) Create a new memory-backed attribute.Open a newInputStreamthat reads this form field.longgetSize()Get the definite size in bytes of the form field value.booleanThe completed part objects passed to a controller are closed when the associated request ends.Read all data of this form field into memory.Methods inherited from class CompletedPart
getBytes, getMetadata, getName
-
Method Details
-
create
Create a new memory-backed attribute. Ownership of the data buffer transfers to the attribute object. Closing the attribute object will close the memory.- Parameters:
metadata- The field metadatareadBuffer- The attribute memory- Returns:
- The attribute
-
isInMemory
public boolean isInMemory()- Specified by:
isInMemoryin classCompletedPart
-
getSize
public long getSize()Description copied from class:CompletedPartGet the definite size in bytes of the form field value. Remains accessible after this part is closed.- Specified by:
getSizein classCompletedPart- Returns:
- The size in bytes
-
getInputStream
Description copied from class:CompletedPartOpen a newInputStreamthat reads this form field. The returned stream must be closed. You must still close thisCompletedPartalso.This is a blocking operation.
- Specified by:
getInputStreamin classCompletedPart- Returns:
- A stream
-
toReadBuffer
Description copied from class:CompletedPartRead 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.
- Specified by:
toReadBufferin classCompletedPart- Returns:
- The buffered value
-
moveResource
Description copied from class:CompletedPartThe 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.- Specified by:
moveResourcein classCompletedPart- Returns:
- A new completed part
-
closeAsync
Description copied from class:CompletedPartCloseable.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.- Specified by:
closeAsyncin classCompletedPart- Parameters:
ioExecutor- The executor
-
close
public void close()
-