Package org.apache.wicket.util.upload

Examples of org.apache.wicket.util.upload.ServletFileUpload


      throw new IllegalStateException(
        "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
    }

    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // especially if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // The encoding can also be null when using multipart/form-data encoded forms.
    // In that case we use the [application-encoding] which we always demand using
    // the attribute 'accept-encoding' in wicket forms.
    if (encoding == null)
    {
      encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding();
    }

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (final FileItem item : items)
    {
View Full Code Here


    }

    DiskFileItemFactory factory = new DiskFileItemFactory();

    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (Iterator<FileItem> i = items.iterator(); i.hasNext();)
    {
View Full Code Here

      throw new IllegalStateException(
        "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
    }

    // Configure the factory here, if desired.
    ServletFileUpload fileUpload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // especially if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // The encoding can also be null when using multipart/form-data encoded forms.
    // In that case we use the [application-encoding] which we always demand using
    // the attribute 'accept-encoding' in wicket forms.
    if (encoding == null)
    {
      encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding();
    }

    // set encoding specifically when we found it
    if (encoding != null)
    {
      fileUpload.setHeaderEncoding(encoding);
    }

    fileUpload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = fileUpload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = fileUpload.parseRequest(request);
    }

    // Loop through items
    for (final FileItem item : items)
    {
View Full Code Here

            System.out.println("not an upload...");
            return;
        }
        try {

            ServletFileUpload upload = new ServletFileUpload(
                    new DiskFileItemFactory(new FileCleaner()));
            List<FileItem> items = upload.parseRequest(req);

            for (FileItem item : items) {

                if (Utils.isBlank(item.getName()))
                    continue;
View Full Code Here

    }

    DiskFileItemFactory factory = new DiskFileItemFactory();

    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (Iterator i = items.iterator(); i.hasNext();)
    {
View Full Code Here

      throw new IllegalStateException("ServletRequest does not contain multipart content");
    }


    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (Iterator<FileItem> i = items.iterator(); i.hasNext();)
    {
View Full Code Here

        "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
    }


    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (Iterator<FileItem> i = items.iterator(); i.hasNext();)
    {
View Full Code Here

      throw new IllegalStateException(
        "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
    }

    // Configure the factory here, if desired.
    ServletFileUpload fileUpload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // especially if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // The encoding can also be null when using multipart/form-data encoded forms.
    // In that case we use the [application-encoding] which we always demand using
    // the attribute 'accept-encoding' in wicket forms.
    if (encoding == null)
    {
      encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding();
    }

    // set encoding specifically when we found it
    if (encoding != null)
    {
      fileUpload.setHeaderEncoding(encoding);
    }

    fileUpload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = fileUpload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = fileUpload.parseRequest(request);
    }

    // Loop through items
    for (final FileItem item : items)
    {
View Full Code Here

    }

    DiskFileItemFactory factory = new DiskFileItemFactory();

    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (Iterator i = items.iterator(); i.hasNext();)
    {
View Full Code Here

        "ServletRequest does not contain multipart content. One possible solution is to explicitly call Form.setMultipart(true), Wicket tries its best to auto-detect multipart forms but there are certain situation where it cannot.");
    }


    // Configure the factory here, if desired.
    ServletFileUpload upload = new ServletFileUpload(factory);

    // The encoding that will be used to decode the string parameters
    // It should NOT be null at this point, but it may be
    // if the older Servlet API 2.2 is used
    String encoding = request.getCharacterEncoding();

    // set encoding specifically when we found it
    if (encoding != null)
    {
      upload.setHeaderEncoding(encoding);
    }

    upload.setSizeMax(maxSize.bytes());

    final List<FileItem> items;

    if (wantUploadProgressUpdates())
    {
      ServletRequestContext ctx = new ServletRequestContext(request)
      {
        @Override
        public InputStream getInputStream() throws IOException
        {
          return new CountingInputStream(super.getInputStream());
        }
      };
      totalBytes = request.getContentLength();

      onUploadStarted(totalBytes);
      items = upload.parseRequest(ctx);
      onUploadCompleted();

    }
    else
    {
      items = upload.parseRequest(request);
    }

    // Loop through items
    for (Iterator<FileItem> i = items.iterator(); i.hasNext();)
    {
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.upload.ServletFileUpload

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.