Class SystemFile
- java.lang.Object
-
- io.micronaut.http.server.types.files.SystemFile
-
- All Implemented Interfaces:
CustomizableResponseType,FileCustomizableResponseType
public class SystemFile extends java.lang.Object implements FileCustomizableResponseType
Used as the return value of a route execution to sendFileinstances to the client. More efficient thanStreamedFile.- Since:
- 1.1.0
-
-
Field Summary
-
Fields inherited from interface io.micronaut.http.server.types.files.FileCustomizableResponseType
ATTACHMENT_HEADER
-
-
Constructor Summary
Constructors Constructor Description SystemFile(java.io.File file)SystemFile(java.io.File file, io.micronaut.http.MediaType mediaType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SystemFileattach()Sets the file to be downloaded as an attachment.SystemFileattach(java.lang.String attachmentName)Sets the file to be downloaded as an attachment.java.io.FilegetFile()longgetLastModified()longgetLength()io.micronaut.http.MediaTypegetMediaType()voidprocess(io.micronaut.http.MutableHttpResponse response)Modify the response before it is written to the client.
-
-
-
Method Detail
-
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
public io.micronaut.http.MediaType getMediaType()
- Specified by:
getMediaTypein interfaceFileCustomizableResponseType- Returns:
- The media type of the file
-
getFile
public java.io.File getFile()
- Returns:
- The file
-
attach
public SystemFile 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
public SystemFile attach(java.lang.String attachmentName)
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
public void process(io.micronaut.http.MutableHttpResponse response)
Description copied from interface:CustomizableResponseTypeModify the response before it is written to the client.- Specified by:
processin interfaceCustomizableResponseType- Parameters:
response- The response to modify
-
-