Class SystemFile
java.lang.Object
io.micronaut.http.server.types.files.SystemFile
- All Implemented Interfaces:
MediaTypeProvider,CustomizableResponseType,FileCustomizableResponseType
Used as the return value of a route execution to send
File instances to the client. More efficient
than StreamedFile.- Since:
- 1.1.0
- Author:
- James Kleeh
-
Field Summary
Fields inherited from interface io.micronaut.http.server.types.files.FileCustomizableResponseType
ATTACHMENT_HEADER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattach()Sets the file to be downloaded as an attachment.Sets the file to be downloaded as an attachment.getFile()longlongvoidprocess(MutableHttpResponse response) Modify the response before it is written to the client.
-
Constructor Details
-
SystemFile
- Parameters:
file- The file to respond with
-
SystemFile
- Parameters:
file- The file to respond withmediaType- The content type of the response
-
-
Method Details
-
getLastModified
public long getLastModified()- Specified by:
getLastModifiedin interfaceFileCustomizableResponseType- Returns:
- The last modified date of the file
-
getLength
public long getLength()- Specified by:
getLengthin interfaceFileCustomizableResponseType- Returns:
- The length of the file
-
getMediaType
- Specified by:
getMediaTypein interfaceMediaTypeProvider- Returns:
- The media type of the object.
-
getFile
- Returns:
- The file
-
attach
Sets the file to be downloaded as an attachment. The file name is set in the Content-Disposition header.- Returns:
- The same SystemFile instance
-
attach
Sets the file to be downloaded as an attachment. The name is set in the Content-Disposition header.- Parameters:
attachmentName- The attachment name.- Returns:
- The same SystemFile instance
-
process
Description copied from interface:CustomizableResponseTypeModify the response before it is written to the client.- Specified by:
processin interfaceCustomizableResponseType- Parameters:
response- The response to modify
-