Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.RequestContext


     *
     * @param req  the request.
     * @return a new request context.
     */
    private RequestContext createRequestContext(final HttpServletRequest req) {
        return new RequestContext() {
            public String getCharacterEncoding() {
                return req.getCharacterEncoding();
            }

            public String getContentType() {
View Full Code Here


    @SuppressWarnings("unchecked")
    public static Map<String, byte[]> parseMultipart(final RequestHeader header, final serverObjects args, final InputStream in) throws IOException {

        final InputStream body = prepareBody(header, in);

        final RequestContext request = new yacyContextRequest(header, body);

        // check information
        if (!FileUploadBase.isMultipartContent(request)) {
            throw new IOException("the request is not a multipart-message!");
        }

        // reject too large uploads
        if (request.getContentLength() > SIZE_FILE_THRESHOLD) throw new IOException("FileUploadException: uploaded file too large = " + request.getContentLength());

        // check if we have enough memory
        if (!MemoryControl.request(request.getContentLength() * 3, false)) {
          throw new IOException("not enough memory available for request. request.getContentLength() = " + request.getContentLength() + ", MemoryControl.available() = " + MemoryControl.available());
        }

        // parse data in memory
        final List<FileItem> items;

View Full Code Here

     *
     * @param req the request.
     * @return a new request context.
     */
    protected RequestContext createRequestContext(final HttpServletRequest req) {
        return new RequestContext() {
            public String getCharacterEncoding() {
                return req.getCharacterEncoding();
            }

            public String getContentType() {
View Full Code Here

  public MultPartForm(final HttpServletRequest request) throws FileUploadException {
    Assert.notNull(request, "request");
    this.parameters = new HashMap<String, String>();
    this.files = new HashMap<String, FileItem>();

    RequestContext requestContext = new ServletRequestContext(request);

    if (FileUploadBase.isMultipartContent(requestContext)) {
      List<?> items = MultPartForm.upload.parseRequest(requestContext);
      Iterator<?> i = items.iterator();
      while (i.hasNext()) {
View Full Code Here

    }
  }

  public static String getParameter(final HttpServletRequest request, final String parameter) throws FileUploadException {
    String value = null;
    RequestContext requestContext = new ServletRequestContext(request);

    if (FileUploadBase.isMultipartContent(requestContext)) {
      List<?> items = MultPartForm.upload.parseRequest(requestContext);
      Iterator<?> i = items.iterator();
      while (i.hasNext()) {
View Full Code Here

    return value;
  }

  public static InputStream getFile(final HttpServletRequest request, final String parameter) throws FileUploadException, IOException {
    InputStream value = null;
    RequestContext requestContext = new ServletRequestContext(request);

    if (FileUploadBase.isMultipartContent(requestContext)) {
      List<?> items = MultPartForm.upload.parseRequest(requestContext);
      Iterator<?> i = items.iterator();
      while (i.hasNext()) {
View Full Code Here

  public MultPartForm(final HttpServletRequest request) throws FileUploadException {
    Assert.notNull(request, "request");
    this.parameters = new HashMap<String, String>();
    this.files = new HashMap<String, FileItem>();

    RequestContext requestContext = new ServletRequestContext(request);

    if (FileUploadBase.isMultipartContent(requestContext)) {
      List<?> items = MultPartForm.upload.parseRequest(requestContext);
      Iterator<?> i = items.iterator();
      while (i.hasNext()) {
View Full Code Here

    }
  }

  public static String getParameter(final HttpServletRequest request, final String parameter) throws FileUploadException {
    String value = null;
    RequestContext requestContext = new ServletRequestContext(request);

    if (FileUploadBase.isMultipartContent(requestContext)) {
      List<?> items = MultPartForm.upload.parseRequest(requestContext);
      Iterator<?> i = items.iterator();
      while (i.hasNext()) {
View Full Code Here

    return value;
  }

  public static InputStream getFile(final HttpServletRequest request, final String parameter) throws FileUploadException, IOException {
    InputStream value = null;
    RequestContext requestContext = new ServletRequestContext(request);

    if (FileUploadBase.isMultipartContent(requestContext)) {
      List<?> items = MultPartForm.upload.parseRequest(requestContext);
      Iterator<?> i = items.iterator();
      while (i.hasNext()) {
View Full Code Here

         }
         return fac;
      }

      private RequestContext createRequestContext(final HttpServletRequest req) {
         return new RequestContext() {

            public String getCharacterEncoding() {
               return req.getCharacterEncoding();
            }
View Full Code Here

TOP

Related Classes of org.apache.commons.fileupload.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.