Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.FileItemStream.openStream()


            // Copy the stream of file data to a temporary file. NOTE: This is necessary even if the
            // current field is a simple form-field because the call below to diskFileItem.getString()
            // will fail otherwise.
            DiskFileItem diskFileItem = (DiskFileItem) diskFileItemFactory.createItem(fieldName,
                contentType, formField, fileName);
            Streams.copy(fieldStream.openStream(), diskFileItem.getOutputStream(), true);

            // If the current field is a simple form-field, then save the form field value in the map.
            if (diskFileItem.isFormField()) {
              String characterEncoding = clientDataRequest.getCharacterEncoding();
              String requestParameterValue = null;
View Full Code Here


        FileItemIterator iterator = upload.getItemIterator(req);

        while (iterator.hasNext()) {
          FileItemStream item = iterator.next();
          if (item.getFieldName() != null && item.getFieldName().equals("errorCode")) {
            String val = read(item.openStream());
            try {
              errorCode = Integer.parseInt(val);
            } catch(NumberFormatException e) {}
            continue;
          }
View Full Code Here

              errorCode = Integer.parseInt(val);
            } catch(NumberFormatException e) {}
            continue;
          }
          if (item.getFieldName() != null && item.getFieldName().equals("errorMessage")) {
            String val = read(item.openStream());
            errorMsg = val;
            continue;
          }
          sb.append("{");
          sb.append("\"fieldName\":\"").append(item.getFieldName()).append("\",");
View Full Code Here

          sb.append("\"fieldName\":\"").append(item.getFieldName()).append("\",");
          if (item.getName() != null) {
            sb.append("\"name\":\"").append(item.getName()).append("\",");
          }
          if (item.getName() != null) {
            sb.append("\"size\":\"").append(size(item.openStream())).append("\"");
          } else {
            sb.append("\"value\":\"").append(read(item.openStream())).append("\"");
          }
          sb.append("}");
          if (iterator.hasNext()) {
View Full Code Here

            sb.append("\"name\":\"").append(item.getName()).append("\",");
          }
          if (item.getName() != null) {
            sb.append("\"size\":\"").append(size(item.openStream())).append("\"");
          } else {
            sb.append("\"value\":\"").append(read(item.openStream())).append("\"");
          }
          sb.append("}");
          if (iterator.hasNext()) {
            sb.append(",");
          }
View Full Code Here

     
      FileItemIterator iter = upload.getItemIterator(request);
      while (iter.hasNext()) {
          FileItemStream item = iter.next();
          String name = item.getFieldName();
          InputStream stream = item.openStream();
          if (item.isFormField()) {
            String value = Streams.asString(stream);

            logger.info("Upload "+name+":"+value);
           
View Full Code Here

        while (iter.hasNext()) {
          FileItemStream item = iter.next();
          if (item.getFieldName().equals("override")) {
            override = true;
          } else if (item.getFieldName().equals("data")) {
            data = new JSONObject(Streams.asString(item.openStream()));
          }
        }
        checkRunState(override);
        inputData = data;
        setUp();
View Full Code Here

        // Parse the request
        FileItemIterator iter = upload.getItemIterator( request );
        while ( iter.hasNext() ) {
          FileItemStream item = iter.next();
          String name = item.getFieldName();
          InputStream stream = item.openStream();
          if ( item.isFormField() ) {
            System.out.println( "Form field " + name + " with value " + Streams.asString( stream )
                + " detected." );
          } else {
            System.out.println( "File field " + name + " with file name " + item.getName() + " detected." );
View Full Code Here

      ServletFileUpload upload = new ServletFileUpload();
      //res.setContentType("text/plain");
      FileItemIterator iterator = upload.getItemIterator(req);
      while (iterator.hasNext()) {
        FileItemStream item = iterator.next();
        InputStream stream = item.openStream();
        //log.warning("diagnosisIdParam: " + diagnosisIdParam);
        if (item.isFormField()) {
           //log.warning("Got a form field: " + item.getFieldName());
          
        } else {
View Full Code Here

      ServletFileUpload upload = new ServletFileUpload();
      try {
        FileItemIterator iter = upload.getItemIterator(req);
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            InputStream input = item.openStream();

            // Handle a form field.
            if(item.isFormField()){
                String fileName = item.getFieldName();
                String value = Streams.asString(input);
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.