Package io.micronaut.http.server.body
Class FileBodyWriter
java.lang.Object
io.micronaut.http.server.body.FileBodyWriter
- All Implemented Interfaces:
MessageBodyWriter<File>,ResponseBodyWriter<File>
@Internal
@Singleton
public final class FileBodyWriter
extends Object
implements ResponseBodyWriter<File>
Body writer for
Files.- Since:
- 4.0.0
- Author:
- Graeme Rocher
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionwrite(@NonNull ByteBodyFactory bodyFactory, HttpRequest<?> request, MutableHttpResponse<File> outgoingResponse, Argument<File> type, MediaType mediaType, File object) Writes an object as aByteBodyHttpResponse.writePiece(@NonNull ByteBodyFactory bodyFactory, @NonNull HttpRequest<?> request, @NonNull HttpResponse<?> response, @NonNull Argument<File> type, @NonNull MediaType mediaType, File object) Write a piece of a larger response, e.g.voidwriteTo(Argument<File> type, MediaType mediaType, File object, MutableHeaders outgoingHeaders, OutputStream outputStream) Writes an object to the given output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, isWriteable, writeTo
-
Constructor Details
-
FileBodyWriter
-
-
Method Details
-
write
public ByteBodyHttpResponse<?> write(@NonNull @NonNull ByteBodyFactory bodyFactory, HttpRequest<?> request, MutableHttpResponse<File> outgoingResponse, Argument<File> type, MediaType mediaType, File object) throws CodecException Description copied from interface:ResponseBodyWriterWrites an object as aByteBodyHttpResponse.- Specified by:
writein interfaceResponseBodyWriter<File>- Parameters:
bodyFactory- The buffer factoryrequest- The requestoutgoingResponse- The responsetype- The response body typemediaType- The media typeobject- The object to write- Returns:
- A
ByteBodyHttpResponsewith the response bytes - Throws:
CodecException- If an error occurs encoding
-
writePiece
public CloseableByteBody writePiece(@NonNull @NonNull ByteBodyFactory bodyFactory, @NonNull @NonNull HttpRequest<?> request, @NonNull @NonNull HttpResponse<?> response, @NonNull @NonNull Argument<File> type, @NonNull @NonNull MediaType mediaType, File object) Description copied from interface:ResponseBodyWriterWrite a piece of a larger response, e.g. when writing a Publisher or a part of a multipart response. In this case, response headers cannot be modified.- Specified by:
writePiecein interfaceResponseBodyWriter<File>- Parameters:
bodyFactory- The buffer factoryrequest- The requestresponse- The response this piece is part oftype- The type of this piecemediaType- The media type of this pieceobject- The piece to write- Returns:
- The response bytes
-
writeTo
public void writeTo(Argument<File> type, MediaType mediaType, File object, MutableHeaders outgoingHeaders, OutputStream outputStream) throws CodecException Description copied from interface:MessageBodyWriterWrites an object to the given output stream.- Specified by:
writeToin interfaceMessageBodyWriter<File>- Parameters:
type- The typemediaType- The media typeobject- The object to writeoutgoingHeaders- The HTTP headersoutputStream- The output stream- Throws:
CodecException- If an error occurs decoding
-