jetbrick-webmvc/src/main/java/jetbrick/web/mvc/multipart/FileUploaderUtils.java
private static MultipartRequest asMultipartRequest(HttpServletRequest request) throws Exception {
        String encoding = request.getCharacterEncoding();

        MultipartRequest req = new MultipartRequest(request);
        ServletFileUpload upload = new ServletFileUpload();
        upload.setHeaderEncoding(encoding);
        FileItemIterator it = upload.getItemIterator(request);

        while (it.hasNext()) {
            FileItemStream item = it.next();
            String fieldName = item.getFieldName();
            InputStream stream = item.openStream();
            try {
                if (item.isFormField()) {
                    req.setParameter(fieldName, Streams.asString(stream, encoding));
                } else {
                    String originalFilename = item.getName();
                    File diskFile = getTempFile(originalFilename);
                    OutputStream fos = new FileOutputStream(diskFile);

                    try {
                        IoUtils.copy(stream, fos);
                    } finally {
                        IoUtils.closeQuietly(fos);
                    }

                    FilePart filePart = new FilePart(fieldName, originalFilename, diskFile);
                    req.addFile(filePart);
                }
            } finally {
                IoUtils.closeQuietly(stream);
            }
        }

        return req;
    }
private static MultipartRequest asMultipartRequest(HttpServletRequest request) throws Exception {
        String encoding = request.getCharacterEncoding();

        MultipartRequest req = new MultipartRequest(request);
        ServletFileUpload upload = new ServletFileUpload();
        upload.setHeaderEncoding(encoding);
        FileItemIterator it = upload.getItemIterator(request);

        while (it.hasNext()) {
            FileItemStream item = it.next();
            String fieldName = item.getFieldName();
            InputStream stream = item.openStream();
            try {
                if (item.isFormField()) {
                    req.setParameter(fieldName, Streams.asString(stream, encoding));
                } else {
                    String originalFilename = item.getName();
                    File diskFile = getTempFile(originalFilename);
                    OutputStream fos = new FileOutputStream(diskFile);

                    try {
                        IoUtils.copy(stream, fos);
                    } finally {
                        IoUtils.closeQuietly(fos);
                    }

                    FilePart filePart = new FilePart(fieldName, originalFilename, diskFile);
                    req.addFile(filePart);
                }
            } finally {
                IoUtils.closeQuietly(stream);
            }
        }

        return req;
    }
private static MultipartRequest asMultipartRequest ( HttpServletRequest request ) throws Exception { String encoding = request . getCharacterEncoding ( ) ; MultipartRequest req = new MultipartRequest ( request ) ; ServletFileUpload upload = new ServletFileUpload ( ) ; upload . setHeaderEncoding ( encoding ) ; FileItemIterator it = upload . getItemIterator ( request ) ; while ( it . hasNext ( ) ) { FileItemStream item = it . next ( ) ; String fieldName = item . getFieldName ( ) ; InputStream stream = item . openStream ( ) ; try { if ( item . isFormField ( ) ) { req . setParameter ( fieldName , Streams . asString ( stream , encoding ) ) ; } else { String originalFilename = item . getName ( ) ; File diskFile = getTempFile ( originalFilename ) ; OutputStream fos = new FileOutputStream ( diskFile ) ; try { IoUtils . copy ( stream , fos ) ; } finally { IoUtils . closeQuietly ( fos ) ; } FilePart filePart = new FilePart ( fieldName , originalFilename , diskFile ) ; req . addFile ( filePart ) ; } } finally { IoUtils . closeQuietly ( stream ) ; } } return req ; }
multipart/form-data
multipart / form - data