Package jodd.upload

Examples of jodd.upload.MultipartStreamParser


    }

    if (mediaType.equals("multipart/form-data")) {
      form = new HttpValuesMap();

      MultipartStreamParser multipartParser = new MultipartStreamParser();

      try {
        byte[] bodyBytes = bodyString.getBytes(StringPool.ISO_8859_1);
        ByteArrayInputStream bin = new ByteArrayInputStream(bodyBytes);
        multipartParser.parseRequestStream(bin, charset);
      } catch (IOException ioex) {
        throw new HttpException(ioex);
      }

      // string parameters
      for (String paramName : multipartParser.getParameterNames()) {
        String[] values = multipartParser.getParameterValues(paramName);
        if (values.length == 1) {
          form.add(paramName, values[0]);
        } else {
          form.put(paramName, values);
        }
      }

      // file parameters
      for (String paramName : multipartParser.getFileParameterNames()) {
        FileUpload[] values = multipartParser.getFiles(paramName);
        if (values.length == 1) {
          form.add(paramName, values[0]);
        } else {
          form.put(paramName, values);
        }
View Full Code Here


    }

    if (mediaType.equals("multipart/form-data")) {
      form = HttpValuesMap.ofObjects();

      MultipartStreamParser multipartParser = new MultipartStreamParser();

      try {
        byte[] bodyBytes = bodyString.getBytes(StringPool.ISO_8859_1);
        ByteArrayInputStream bin = new ByteArrayInputStream(bodyBytes);
        multipartParser.parseRequestStream(bin, charset);
      } catch (IOException ioex) {
        throw new HttpException(ioex);
      }

      // string parameters
      for (String paramName : multipartParser.getParameterNames()) {
        String[] values = multipartParser.getParameterValues(paramName);
        if (values.length == 1) {
          form.add(paramName, values[0]);
        } else {
          form.put(paramName, values);
        }
      }

      // file parameters
      for (String paramName : multipartParser.getFileParameterNames()) {
        FileUpload[] values = multipartParser.getFiles(paramName);
        if (values.length == 1) {
          form.add(paramName, values[0]);
        } else {
          form.put(paramName, values);
        }
View Full Code Here

TOP

Related Classes of jodd.upload.MultipartStreamParser

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.