public class FileStreamer
extends java.lang.Object
Constructor and Description |
---|
FileStreamer(java.nio.file.Path content,
org.springframework.http.MediaType contentType,
java.util.function.Consumer<javax.servlet.http.HttpServletResponse> cacheStrategy)
Creates a new instance to stream the specified file.
|
Modifier and Type | Method and Description |
---|---|
org.springframework.http.ResponseEntity<java.lang.String> |
streamOr404(javax.servlet.http.HttpServletResponse response)
Streams the file to the client or sends back a 404 if the file does not
exist.
|
public FileStreamer(java.nio.file.Path content, org.springframework.http.MediaType contentType, java.util.function.Consumer<javax.servlet.http.HttpServletResponse> cacheStrategy)
content
- path to the file to stream.contentType
- the content type to set in the response.cacheStrategy
- sets cache directives in the response.java.lang.NullPointerException
- if any argument is null
.public org.springframework.http.ResponseEntity<java.lang.String> streamOr404(javax.servlet.http.HttpServletResponse response) throws java.io.IOException
response
- the response to send to the client.java.io.IOException
- if an I/O error occurs.java.lang.NullPointerException
- if the argument is null
.