Interface UploadService

  • All Known Implementing Classes:
    DefaultUploadService

    public interface UploadService

    This service handles parsing multipart/form-data POST requests and turning them into form fields and uploaded files. This can be either performed automatically by the org.apache.fulcrum.parser.ParameterParser or manually by a user defined org.apache.turbine.modules.Action.

    Version:
    $Id$
    Author:
    Rafal Krzewski, Daniel Rall
    • Method Detail

      • parseRequest

        List<org.apache.commons.fileupload.FileItem> parseRequest​(HttpServletRequest req)
                                                           throws org.apache.avalon.framework.service.ServiceException

        Parses a RFC 1867 compliant multipart/form-data stream.

        Parameters:
        req - The servlet request to be parsed.
        Returns:
        list of file items
        Throws:
        org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).
      • parseRequest

        List<org.apache.commons.fileupload.FileItem> parseRequest​(HttpServletRequest req,
                                                                  String path)
                                                           throws org.apache.avalon.framework.service.ServiceException

        Parses a RFC 1867 compliant multipart/form-data stream.

        Parameters:
        req - The servlet request to be parsed.
        path - The location where the files should be stored.
        Returns:
        List of FileItem parts
        Throws:
        org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).
      • parseRequest

        List<org.apache.commons.fileupload.FileItem> parseRequest​(HttpServletRequest req,
                                                                  int sizeThreshold,
                                                                  int sizeMax,
                                                                  String path)
                                                           throws org.apache.avalon.framework.service.ServiceException

        Parses a RFC 1867 compliant multipart/form-data stream.

        Parameters:
        req - The servlet request to be parsed.
        sizeThreshold - the max size in bytes to be stored in memory
        sizeMax - the maximum allowed upload size in bytes
        path - The location where the files should be stored.
        Returns:
        List of FileItem parts
        Throws:
        org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).
      • getItemIterator

        org.apache.commons.fileupload.FileItemIterator getItemIterator​(HttpServletRequest req)
                                                                throws org.apache.avalon.framework.service.ServiceException
        Processes an RFC 1867 compliant multipart/form-data stream.
        Parameters:
        req - The servlet request to be parsed.
        Returns:
        An iterator to instances of FileItemStream parsed from the request, in the order that they were transmitted.
        Throws:
        org.apache.avalon.framework.service.ServiceException - if there are problems reading/parsing the request or storing files. This may also be a network error while communicating with the client or a problem while storing the uploaded content.
      • parseRequest

        List<org.apache.commons.fileupload.FileItem> parseRequest​(javax.portlet.ActionRequest req)
                                                           throws org.apache.avalon.framework.service.ServiceException

        Parses a RFC 1867 compliant multipart/form-data stream.

        Parameters:
        req - The portlet request to be parsed.
        Returns:
        List of FileItem parts
        Throws:
        org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).
      • parseRequest

        List<org.apache.commons.fileupload.FileItem> parseRequest​(javax.portlet.ActionRequest req,
                                                                  String path)
                                                           throws org.apache.avalon.framework.service.ServiceException

        Parses a RFC 1867 compliant multipart/form-data stream.

        Parameters:
        req - The portlet request to be parsed.
        path - The location where the files should be stored.
        Returns:
        List of FileItem parts
        Throws:
        org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).
      • parseRequest

        List<org.apache.commons.fileupload.FileItem> parseRequest​(javax.portlet.ActionRequest req,
                                                                  int sizeThreshold,
                                                                  int sizeMax,
                                                                  String path)
                                                           throws org.apache.avalon.framework.service.ServiceException

        Parses a RFC 1867 compliant multipart/form-data stream.

        Parameters:
        req - The portlet request to be parsed.
        sizeThreshold - the max size in bytes to be stored in memory
        sizeMax - the maximum allowed upload size in bytes
        path - The location where the files should be stored.
        Returns:
        The list of FileItem parts uploaded
        Throws:
        org.apache.avalon.framework.service.ServiceException - Problems reading/parsing the request or storing the uploaded file(s).
      • getItemIterator

        org.apache.commons.fileupload.FileItemIterator getItemIterator​(javax.portlet.ActionRequest req)
                                                                throws org.apache.avalon.framework.service.ServiceException
        Processes an RFC 1867 compliant multipart/form-data stream.
        Parameters:
        req - The portlet request to be parsed.
        Returns:
        An iterator to instances of FileItemStream parsed from the request, in the order that they were transmitted.
        Throws:
        org.apache.avalon.framework.service.ServiceException - if there are problems reading/parsing the request or storing files. This may also be a network error while communicating with the client or a problem while storing the uploaded content.
      • getSizeMax

        long getSizeMax()

        Retrieves the value of size.max property of the UploadService.

        Returns:
        The maximum upload size.
      • getSizeThreshold

        long getSizeThreshold()

        Retrieves the value of size.threshold property of UploadService.

        Returns:
        The threshold beyond which files are written directly to disk.
      • isMultipart

        boolean isMultipart​(HttpServletRequest req)
        Utility method that determines whether the request contains multipart content.
        Parameters:
        req - The servlet request to be evaluated. Must be non-null.
        Returns:
        true if the request is multipart; false otherwise.
      • isMultipart

        boolean isMultipart​(javax.portlet.ActionRequest req)
        Utility method that determines whether the request contains multipart content.
        Parameters:
        req - The portlet request to be evaluated. Must be non-null.
        Returns:
        true if the request is multipart; false otherwise.