Class FileServingServlet

  • All Implemented Interfaces:
    MultipartRequestWrapper.ParsingStrategy, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    @WebServlet(name="serveFiles",
                urlPatterns="/file/*")
    public class FileServingServlet
    extends VitroHttpServlet

    Handles a request to serve an uploaded file from the file storage system.

    The path of the request should be the "alias URL" of the desired file. We need to:

    • Use the alias URL to find the URI of the file bytestream object.
    • Find the file surrogate object to get the MIME type of the file, and confirm the filename.
    • Set the MIME type on the output stream and serve the bytes.

    If the request is superficially correct, but no such file can be found, return a 404. If there is a break in the data structures within the model or the file system, return a 500.

    See Also:
    Serialized Form
    • Constructor Detail

      • FileServingServlet

        public FileServingServlet()
    • Method Detail

      • init

        public void init()
                  throws javax.servlet.ServletException
        Get a reference to the File Storage system.
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest rawRequest,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
        Description copied from class: VitroHttpServlet
        doGet does nothing.
        Overrides:
        doGet in class VitroHttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              IOException
        A POST request is treated the same as a GET request.
        Overrides:
        doPost in class VitroHttpServlet
        Throws:
        javax.servlet.ServletException
        IOException