Package org.apache.commons.fileupload.servlet

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest()


            }
            upload.setSizeMax(maxUploadSize);

            List<FileItem> uploadedItems = null;
            try {
                uploadedItems = UtilGenerics.<FileItem>checkList(upload.parseRequest(request));
            } catch (FileUploadException e) {
                throw new EventHandlerException("Problems reading uploaded data", e);
            }
            if (uploadedItems != null) {
                for (FileItem item: uploadedItems) {
View Full Code Here


            }
        };

        // Parse the request
        try {
            List<?> /* FileItem */items = upload.parseRequest(rc);
            for (Iterator<?> ii = items.iterator(); ii.hasNext();) {
                FileItem fileItem = (FileItem) ii.next();
                RequestParameter pp = new MultipartRequestParameter(fileItem);
                parameters.addParameter(fileItem.getFieldName(), pp);
            }
View Full Code Here

    try {
      boolean isMultipart = ServletFileUpload.isMultipartContent(req);
      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);
      // FileItemIterator iter1 = upload.getItemIterator(req);
      List items = upload.parseRequest(req);

      /*
       * Formularz wysylany jest jako multipart, wiec nie uzyskamy
       * normalnego dostepu do pol potrzeba jest uzyskiwac je poprzez
       * biblioteke apache-commons. Dla uniwersalnosci formularza, mozna
View Full Code Here

    try {
      boolean isMultipart = ServletFileUpload.isMultipartContent(req);
      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);
      //FileItemIterator iter1 = upload.getItemIterator(req);
      List items = upload.parseRequest(req);
     
      /*
       * Formularz wysylany jest jako multipart, wiec nie uzyskamy normalnego dostepu do pol
       * potrzeba jest uzyskiwac je poprzez biblioteke apache-commons.
       * Dla uniwersalnosci formularza, mozna dodac opcje w przypadku gdy jest przesylany
View Full Code Here

      monitor = new ProgressMonitor();
      upload.setProgressListener(monitor);
      servletRequest.getSession().setAttribute(ProgressMonitor.SESSION_PROGRESS_MONITOR, monitor);

      List items = upload.parseRequest(createRequestContext(servletRequest));

      for (Object item1 : items) {
    FileItem item = (FileItem) item1;
    if (log.isDebugEnabled())
        log.debug("Found item " + item.getFieldName());
View Full Code Here

   
   
    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

    ServletFileUpload uploader = createServletFileUpload(config);
    uploader.setSizeMax(config.getSizeLimit());

    try {
      final List<FileItem> items = uploader.parseRequest(request);
      logger.debug("Found {} attributes in the multipart form submission. Parsing them.", items.size());


      for (FileItem item : items) {
        String name = item.getFieldName();
View Full Code Here

       
        // There is a possible race condition here. If liveDeploy is true it
        // means the deployer could start to deploy the app before we do it.
        synchronized(getLock()) {
            try {
                List items = upload.parseRequest(request);
           
                // Process the uploaded fields
                Iterator iter = items.iterator();
                while (iter.hasNext()) {
                    FileItem item = (FileItem) iter.next();
View Full Code Here

            "-----1234--\r\n";

        ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
        upload.setFileSizeMax(-1);
        HttpServletRequest req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
        List<FileItem> fileItems = upload.parseRequest(req);
        assertEquals(1, fileItems.size());
        FileItem item = fileItems.get(0);
        assertEquals("This is the content of the file\n", new String(item.get()));

        upload = new ServletFileUpload(new DiskFileItemFactory());
View Full Code Here

        assertEquals("This is the content of the file\n", new String(item.get()));

        upload = new ServletFileUpload(new DiskFileItemFactory());
        upload.setFileSizeMax(40);
        req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
        fileItems = upload.parseRequest(req);
        assertEquals(1, fileItems.size());
        item = fileItems.get(0);
        assertEquals("This is the content of the file\n", new String(item.get()));

        upload = new ServletFileUpload(new DiskFileItemFactory());
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.