Package io.goobi.viewer.api.rest.model
Class MediaResourceHelper
java.lang.Object
io.goobi.viewer.api.rest.model.MediaResourceHelper
Helper class for serving media resources via the REST API, handling content-type detection,
redirect decisions, and HTTP response header configuration based on viewer media-type settings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetRedirectUrl(String pi, String filename) setContentHeaders(HttpServletRequest servletRequest, HttpServletResponse servletResponse, String filename, Path path, boolean inlineForAllTypes) Sets content type and content disposition headers for the given file.setContentHeaders(HttpServletResponse servletResponse, String filename, Path path) booleanshouldRedirect(String filename)
-
Constructor Details
-
MediaResourceHelper
-
-
Method Details
-
shouldRedirect
- Throws:
IOException
-
getRedirectUrl
- Throws:
IOException
-
setContentHeaders
public String setContentHeaders(HttpServletResponse servletResponse, String filename, Path path) throws IOException - Throws:
IOException
-
setContentHeaders
public String setContentHeaders(HttpServletRequest servletRequest, HttpServletResponse servletResponse, String filename, Path path, boolean inlineForAllTypes) throws IOException Sets content type and content disposition headers for the given file. Requests made by a client application get a plain inline disposition for PDF files, or for all files if inlineForAllTypes is true; all other requests get the disposition configured for the file's mime type.- Parameters:
servletRequest- request used to detect client applications; may be nullservletResponse- response to set the headers onfilename- file name announced in an attachment dispositionpath- path of the delivered file; must be within the viewer home folderinlineForAllTypes- if true, client applications get an inline disposition regardless of the mime type- Returns:
- the probed mime type of the file
- Throws:
IOException
-