Examples of FileItemStream


Examples of org.apache.commons.fileupload.FileItemStream

    ServletFileUpload upload = new ServletFileUpload();
    upload.setSizeMax(50000);
    try {
      FileItemIterator iterator = upload.getItemIterator(req);
      while (iterator.hasNext()) {
        FileItemStream item = iterator.next();
        InputStream in = item.openStream();
        if (item.isFormField()) {
          String fieldName = item.getFieldName();
          if (fieldName.equals("phoneNumber")) {
            phoneNumber = Streams.asString(in, "UTF-8");
          } else if (fieldName.equals("defaultCountry")) {
            defaultCountry = Streams.asString(in).toUpperCase();
          } else if (fieldName.equals("languageCode")) {
View Full Code Here

Examples of org.slim3.controller.upload.FileItemStream

    public void handle() {
        try {
            FileUpload upload = createFileUpload();
            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 =
                        normalizeValue(Streams.asString(stream, request
                            .getCharacterEncoding()));
                    if (name.endsWith(ARRAY_SUFFIX)) {
                        String[] array = (String[]) request.getAttribute(name);
                        if (array == null) {
                            array = new String[0];
                        }
                        request.setAttribute(name, ArrayUtil.add(array, value));
                    } else {
                        request.setAttribute(name, value);
                    }
                } else {
                    ByteArrayOutputStream baos =
                        new ByteArrayOutputStream(BYTE_ARRAY_SIZE);
                    Streams.copy(stream, baos, true);
                    byte[] data = baos.toByteArray();
                    FileItem value =
                        data.length > 0 ? new FileItem(item.getFileName(), item
                            .getContentType(), data) : null;
                    if (name.endsWith(ARRAY_SUFFIX)) {
                        FileItem[] array =
                            (FileItem[]) request.getAttribute(name);
                        if (array == null) {
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.