Class MediaResourceHelper

java.lang.Object
io.goobi.viewer.api.rest.model.MediaResourceHelper

public class MediaResourceHelper extends Object
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 Details

    • MediaResourceHelper

      public MediaResourceHelper(Configuration config)
  • Method Details

    • shouldRedirect

      public boolean shouldRedirect(String filename) throws IOException
      Throws:
      IOException
    • getRedirectUrl

      public String getRedirectUrl(String pi, String filename) throws IOException
      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 null
      servletResponse - response to set the headers on
      filename - file name announced in an attachment disposition
      path - path of the delivered file; must be within the viewer home folder
      inlineForAllTypes - if true, client applications get an inline disposition regardless of the mime type
      Returns:
      the probed mime type of the file
      Throws:
      IOException