Examples of ServletFileUpload


Examples of org.apache.commons.fileupload.servlet.ServletFileUpload

  @SuppressWarnings("unchecked")
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
   
   
    ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
   
        try {
      List<DiskFileItem> fileItems = upload.parseRequest(req);
      for (DiskFileItem fileItem : fileItems) {
        fileItem.write(new File(savePath+"/"+fileItem.getName()));
      }
    } catch (FileUploadException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.apache.tomcat.util.http.fileupload.ServletFileUpload

        }
        if (config.getFileSizeThreshold() > 0) {
            factory.setSizeThreshold(config.getFileSizeThreshold());
        }
       
        ServletFileUpload upload = new ServletFileUpload();
        upload.setFileItemFactory(factory);
        upload.setFileSizeMax(config.getMaxFileSize());
        upload.setSizeMax(config.getMaxRequestSize());

        parts = new HashMap<String, Part>();
        try {
            for (FileItem fileItem : upload.parseRequest(getRequest())) {
                if (fileItem.getName() == null) {
                    coyoteRequest.getParameters().addParameterValues
                        (fileItem.getFieldName(), new String[] {fileItem.getString()});
                }
                parts.put(fileItem.getFieldName(), new StandardPart(fileItem, config));
View Full Code Here

Examples of org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload

            partsParseException = ioe;
            return;
        }
        factory.setSizeThreshold(mce.getFileSizeThreshold());
       
        ServletFileUpload upload = new ServletFileUpload();
        upload.setFileItemFactory(factory);
        upload.setFileSizeMax(mce.getMaxFileSize());
        upload.setSizeMax(mce.getMaxRequestSize());

        parts = new ArrayList<Part>();
        try {
            List<FileItem> items = upload.parseRequest(this);
            for (FileItem item : items) {
                ApplicationPart part = new ApplicationPart(item, mce);
                parts.add(part);
                if (part.getFilename() == null) {
                    try {
View Full Code Here

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
TOP
Copyright © 2018 www.massapi.com. 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.