Java Code Examples for org.apache.commons.fileupload.FileUploadException

The following examples show how to use org.apache.commons.fileupload.FileUploadException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * @see MultiPartManager#getParts(cloud.piranha.webapp.api.WebApplication, cloud.piranha.webapp.api.WebApplicationRequest) 
 */
@Override
public Collection<Part> getParts(WebApplication webApplication,
        WebApplicationRequest request) throws ServletException {

    Collection<Part> parts = new ArrayList<>();
    if (LOGGER.isLoggable(FINE)) {
        LOGGER.log(FINE, "Getting parts for request: {0}", request);
    }
    if (ServletFileUpload.isMultipartContent(request)) {
        try {
            ServletFileUpload upload = setupFileUpload(webApplication);
            List<FileItem> items = upload.parseRequest(request);
            items.forEach((item) -> {
                parts.add(new ApacheMultiPart(item));
            });
        } catch (FileUploadException fue) {
        }
    } else {
        throw new ServletException("Not a multipart/form-data request");
    }
    return parts;
}
 
Example 2
Source Project: multiapps-controller   Source File: FilesApiServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ResponseEntity<FileMetadata> uploadFile(HttpServletRequest request, String spaceGuid, String namespace) {
    try {
        StopWatch stopWatch = StopWatch.createStarted();
        LOGGER.trace("Received upload request on URI: {}", ServletUtil.decodeUri(request));
        FileEntry fileEntry = uploadFiles(request, spaceGuid, namespace).get(0);
        FileMetadata file = parseFileEntry(fileEntry);
        AuditLoggingProvider.getFacade()
                            .logConfigCreate(file);
        stopWatch.stop();
        LOGGER.trace("Uploaded file \"{}\" with name {}, size {} and digest {} (algorithm {}) for {} ms.", file.getId(), file.getName(),
                     file.getSize(), file.getDigest(), file.getDigestAlgorithm(), stopWatch.getTime());
        return ResponseEntity.status(HttpStatus.CREATED)
                             .body(file);
    } catch (FileUploadException | IOException | FileStorageException e) {
        throw new SLException(e, Messages.COULD_NOT_UPLOAD_FILE_0, e.getMessage());
    }
}
 
Example 3
Source Project: multiapps-controller   Source File: FilesApiServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
private List<FileEntry> uploadFiles(HttpServletRequest request, String spaceGuid, String namespace)
    throws FileUploadException, IOException, FileStorageException {
    List<FileEntry> uploadedFiles = new ArrayList<>();
    FileItemIterator fileItemIterator = createFileIterator(request);

    while (fileItemIterator.hasNext()) {
        FileItemStream item = fileItemIterator.next();
        if (item.isFormField()) {
            continue; // ignore simple (non-file) form fields
        }

        try (InputStream in = item.openStream()) {
            FileEntry entry = fileService.addFile(spaceGuid, namespace, item.getName(), in);
            uploadedFiles.add(entry);
        }
    }
    return uploadedFiles;
}
 
Example 4
Source Project: mumu   Source File: UploadUtil.java    License: Apache License 2.0 6 votes vote down vote up
/** 获取所有文本域 */
public static final List<?> getFileItemList(HttpServletRequest request, File saveDir) throws FileUploadException {
	if (!saveDir.isDirectory()) {
		saveDir.mkdir();
	}
	List<?> fileItems = null;
	RequestContext requestContext = new ServletRequestContext(request);
	if (FileUpload.isMultipartContent(requestContext)) {
		DiskFileItemFactory factory = new DiskFileItemFactory();
		factory.setRepository(saveDir);
		factory.setSizeThreshold(fileSizeThreshold);
		ServletFileUpload upload = new ServletFileUpload(factory);
		fileItems = upload.parseRequest(request);
	}
	return fileItems;
}
 
Example 5
/**
 * 
 * processes HTTP-Requests by extracting the form-data. If extraction is
 * successful, data is passed to checkRequestParameter() which also takes on
 * generating a response. If extraction fails a response containing an
 * error-message is returned.
 * 
 * @param request
 * @param context
 * @author Christian Schowalter
 */
public static ProcessCreateResponse handleServlet(
		HttpServletRequest request, ServletContext context) {
	ProcessCreateResponse response = new ProcessCreateResponse(context);

	FormItemList items = null;
	try {
		items = FormItemList.extractFormItems(request, factory);
	} catch (FileUploadException e) {
		e.printStackTrace();
	}

	// items is == null, when request Content-Type is not multipart
	if (items == null) {
		response.addHttpRequestError(CreateStatusCodes.REQUEST_MUST_BE_MULTIPART);
		return response;
	}

	return checkRequestParameter(items, response, context);
}
 
Example 6
private Map<String, String> getMultipartParameterMap()
		throws RepositoryException, IOException, FileUploadException {
	Map<String, String> parameters = new HashMap<>();
	ServletFileUpload upload = new ServletFileUpload();
	FileItemIterator iter = upload.getItemIterator(this);
	while (iter.hasNext()) {
		FileItemStream item = iter.next();
		String name = item.getFieldName();
		if ("content".equals(name)) {
			content = item.openStream();
			contentFileName = item.getName();
			break;
		} else {
			parameters.put(name, firstLine(item));
		}
	}
	return parameters;
}
 
Example 7
Source Project: journaldev   Source File: ActionRequestReader.java    License: MIT License 6 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
	// Handle default MIME type request
	if(request.getContentType().equals("application/x-www-form-urlencoded")){
		String message = request.getParameter("message");
		System.out.println(message);
	}
	// Handle multipart request
	else if(request.getContentType().contains("multipart/form-data")){
		// Create FileItemFactory
		FileItemFactory factory = new DiskFileItemFactory();
		// Create PortletFileUpload instance
		PortletFileUpload fileUpload = new PortletFileUpload(factory);
		try {
			// Instead of parsing the request ourselves, let Apache PortletFileUpload do that
			List<FileItem> files = fileUpload.parseRequest(request);
			// Iterate over files
			for(FileItem item : files){
				// Print out some of information
				System.out.println("File Uploaded Name Is : "+item.getName()+" , Its Size Is :: "+item.getSize());
			}
		} catch (FileUploadException e) {
			e.printStackTrace();
		}
		System.out.println(response.encodeURL("/index.html"));
	}
}
 
Example 8
Source Project: flow   Source File: StreamReceiverHandler.java    License: Apache License 2.0 6 votes vote down vote up
private boolean handleMultipartFileUploadFromInputStream(VaadinSession session,
        VaadinRequest request, StreamReceiver streamReceiver,
        StateNode owner) throws IOException {
    boolean success = true;
    long contentLength = request.getContentLength();
    // Parse the request
    FileItemIterator iter;
    try {
        iter = getItemIterator(request);
        while (iter.hasNext()) {
            FileItemStream item = iter.next();
            boolean itemSuccess = handleStream(session, streamReceiver,
                    owner, contentLength, item);
            success = success && itemSuccess;
        }
    } catch (FileUploadException e) {
        success = false;
        getLogger().warn("File upload failed.", e);
    }
    return success;
}
 
Example 9
Source Project: RestServices   Source File: MicroflowService.java    License: Apache License 2.0 6 votes vote down vote up
private void parseMultipartData(RestServiceRequest rsr, IMendixObject argO,
		JSONObject data) throws IOException, FileUploadException {
	boolean hasFile = false;
	
	for(FileItemIterator iter = servletFileUpload.getItemIterator(rsr.request); iter.hasNext();) {
		FileItemStream item = iter.next();
		if (!item.isFormField()){ //This is the file(?!)
			if (!isFileSource) {
				RestServices.LOGPUBLISH.warn("Received request with binary data but input argument isn't a filedocument. Skipping. At: " + rsr.request.getRequestURL().toString());
				continue;
			}
			if (hasFile)
				RestServices.LOGPUBLISH.warn("Received request with multiple files. Only one is supported. At: " + rsr.request.getRequestURL().toString());
			hasFile = true;
			Core.storeFileDocumentContent(rsr.getContext(), argO, determineFileName(item), item.openStream());
		}
		else
			data.put(item.getFieldName(), IOUtils.toString(item.openStream()));
	}
}
 
Example 10
Source Project: attic-stratos   Source File: AbstractFileUploadExecutor.java    License: Apache License 2.0 6 votes vote down vote up
protected void checkServiceFileExtensionValidity(String fileExtension,
                                                 String[] allowedExtensions)
        throws FileUploadException {
    boolean isExtensionValid = false;
    StringBuffer allowedExtensionsStr = new StringBuffer();
    for (String allowedExtension : allowedExtensions) {
        allowedExtensionsStr.append(allowedExtension).append(",");
        if (fileExtension.endsWith(allowedExtension)) {
            isExtensionValid = true;
            break;
        }
    }
    if (!isExtensionValid) {
        throw new FileUploadException(" Illegal file type." +
                                      " Allowed file extensions are " + allowedExtensionsStr);
    }
}
 
Example 11
Source Project: oryx   Source File: AbstractOryxResource.java    License: Apache License 2.0 6 votes vote down vote up
private Collection<Part> parseMultipartWithCommonsFileUpload(HttpServletRequest request) throws IOException {
  if (sharedFileItemFactory.get() == null) {
    // Not a big deal if two threads actually set this up
    DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(
        1 << 16, (File) servletContext.getAttribute("javax.servlet.context.tempdir"));
    fileItemFactory.setFileCleaningTracker(
        FileCleanerCleanup.getFileCleaningTracker(servletContext));
    sharedFileItemFactory.compareAndSet(null, fileItemFactory);
  }

  try {
    return new ServletFileUpload(sharedFileItemFactory.get()).parseRequest(request)
        .stream().map(FileItemPart::new).collect(Collectors.toList());
  } catch (FileUploadException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 12
@Override
@SuppressWarnings("unchecked")
public Iterator<FileItem> readFrom(Class<Iterator<FileItem>> type,
                                   Type genericType,
                                   Annotation[] annotations,
                                   MediaType mediaType,
                                   MultivaluedMap<String, String> httpHeaders,
                                   InputStream entityStream) throws IOException {
    try {
        ApplicationContext context = ApplicationContext.getCurrent();
        int bufferSize = context.getEverrestConfiguration().getMaxBufferSize();
        DefaultFileItemFactory factory = new DefaultFileItemFactory(bufferSize, FileCollector.getInstance().getStore());
        FileUpload upload = new FileUpload(factory);
        return upload.parseRequest(httpRequest).iterator();
    } catch (FileUploadException e) {
        throw new IOException(String.format("Can't process multipart data item, %s", e));
    }
}
 
Example 13
@SuppressWarnings("unchecked")
@Override
public Iterator<FileItem> readFrom(Class<Iterator<FileItem>> type,
                                   Type genericType,
                                   Annotation[] annotations,
                                   MediaType mediaType,
                                   MultivaluedMap<String, String> httpHeaders,
                                   InputStream entityStream) throws IOException {
    try {
        ApplicationContext context = ApplicationContext.getCurrent();
        int bufferSize = context.getEverrestConfiguration().getMaxBufferSize();
        FileItemFactory factory = new InMemoryItemFactory(bufferSize);
        FileUpload upload = new FileUpload(factory);
        return upload.parseRequest(httpRequest).iterator();
    } catch (FileUploadException e) {
        throw new IOException(String.format("Can't process multipart data item, %s", e));
    }
}
 
Example 14
Source Project: kk-anti-reptile   Source File: ValidateFormService.java    License: Apache License 2.0 5 votes vote down vote up
public String validate(HttpServletRequest request) throws UnsupportedEncodingException {
    DiskFileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);
    upload.setHeaderEncoding("UTF-8");
    List items = null;
    try {
        items = upload.parseRequest(request);
    } catch (FileUploadException e) {
        e.printStackTrace();
    }
    Map<String, String> params = new HashMap<String, String>();
    for(Object object : items){
        FileItem fileItem = (FileItem) object;
        if (fileItem.isFormField()) {
            params.put(fileItem.getFieldName(), fileItem.getString("UTF-8"));
        }
    }
    String verifyId = params.get("verifyId");
    String result =  params.get("result");
    String realRequestUri = params.get("realRequestUri");
    String actualResult = verifyImageUtil.getVerifyCodeFromRedis(verifyId);
    if (actualResult != null && request != null && actualResult.equals(result.toLowerCase())) {
        actuator.reset(request, realRequestUri);
        return "{\"result\":true}";
    }
    return "{\"result\":false}";
}
 
Example 15
private static List<FileItem> parseMultipartRequest(Request request)
        throws FileUploadException {
    DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
    ServletContext servletContext = request.raw().getServletContext();
    File repository = (File) servletContext
            .getAttribute("javax.servlet.context.tempdir");
    fileItemFactory.setRepository(repository);
    return new ServletFileUpload(fileItemFactory).parseRequest(request.raw());
}
 
Example 16
Source Project: freeacs   Source File: ParameterParser.java    License: MIT License 5 votes vote down vote up
/**
 * Instantiates a new parameter parser.
 *
 * @param req the req
 * @throws FileUploadException the file upload exception
 */
public ParameterParser(HttpServletRequest req) throws FileUploadException {
  this.req = new AbstractRequest(req);
  isMultipart = ServletFileUpload.isMultipartContent(req);
  // define files anyway so i can use it to return empty enumeration from getFileUploadNames()
  files = new HashMap<>();
  if (isMultipart) {
    // only define params if i need it
    params = new HashMap<>();
    parseUploadParams(req);
  }
}
 
Example 17
Source Project: s2g-zuul   Source File: FilterScriptManagerServlet.java    License: MIT License 5 votes vote down vote up
private String handlePostBody(HttpServletRequest request, HttpServletResponse response) throws IOException {

        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);
        org.apache.commons.fileupload.FileItemIterator it = null;
        try {
            it = upload.getItemIterator(request);

            while (it.hasNext()) {
                FileItemStream stream = it.next();
                InputStream input = stream.openStream();

                // NOTE: we are going to pull the entire stream into memory
                // this will NOT work if we have huge scripts, but we expect these to be measured in KBs, not MBs or larger
                byte[] uploadedBytes = getBytesFromInputStream(input);
                input.close();

                if (uploadedBytes.length == 0) {
                    setUsageError(400, "ERROR: Body contained no data.", response);
                    return null;
                }

                return new String(uploadedBytes);
            }
        } catch (FileUploadException e) {
            throw new IOException(e.getMessage());
        }
        return null;
    }
 
Example 18
Source Project: common-project   Source File: ControllerAdviceHandler.java    License: Apache License 2.0 5 votes vote down vote up
@ExceptionHandler
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public Object handle(Exception exception) {
    logger.error("错误信息  ====  "+exception.getMessage());
    if (exception instanceof BindException) {
        BindException bindException = (BindException) exception;
        List<FieldError> fieldErrors = bindException.getFieldErrors();
        for (FieldError fieldError : fieldErrors) {
            return ResponseMessage.error(10010,fieldError.getField() + fieldError.getDefaultMessage());
        }
    }

    if (exception instanceof ConstraintViolationException) {
        ConstraintViolationException exs = (ConstraintViolationException) exception;

        Set<ConstraintViolation<?>> violations = exs.getConstraintViolations();
        for (ConstraintViolation<?> violation : violations) {
            return ResponseMessage.error(10010,violation.getPropertyPath() + violation.getMessage());
        }
    }
    if (exception instanceof HandlerException) {
        HandlerException handlerException = (HandlerException) exception;
        return new ResponseMessage(handlerException.getCode(), handlerException.getErrorInfo());
    }
    if (exception instanceof MissingServletRequestParameterException) {
        MissingServletRequestParameterException missingServletRequestParameterException = (MissingServletRequestParameterException) exception;
        return ResponseMessage.error(10010, "请求参数" + missingServletRequestParameterException.getParameterName() + "不能为空");
    }
    if (exception instanceof FileUploadException) {
        FileUploadException fileUploadException = (FileUploadException) exception;
        return ResponseMessage.error(10010, fileUploadException.getMessage());
    }

    return ResponseMessage.error(0, "服务异常");
}
 
Example 19
/**
 * @see MultiPartManager#getPart(cloud.piranha.webapp.api.WebApplication, cloud.piranha.webapp.api.WebApplicationRequest, java.lang.String)
 */
@Override
public Part getPart(WebApplication webApplication,
        WebApplicationRequest request, String name) throws ServletException {

    ApacheMultiPart result = null;
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(FINE, "Getting part: {0} for request: {0}",
                new Object[]{name, request});
    }
    if (ServletFileUpload.isMultipartContent(request)) {
        try {
            ServletFileUpload upload = setupFileUpload(webApplication);
            List<FileItem> items = upload.parseRequest(request);
            for (FileItem item : items) {
                if (item.getName().equals(name)) {
                    result = new ApacheMultiPart(item);
                    break;
                }
            }
        } catch (FileUploadException fue) {
            if (LOGGER.isLoggable(WARNING)) {
                LOGGER.log(WARNING, "Error getting part", fue);
            }
        }
    } else {
        throw new ServletException("Not a multipart/form-data request");
    }
    return result;
}
 
Example 20
Source Project: multiapps-controller   Source File: FilesApiServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
private FileItemIterator createFileIterator(HttpServletRequest request) throws IOException, FileUploadException {
    long maxUploadSize = new Configuration().getMaxUploadSize();
    ServletFileUpload upload = getFileUploadServlet();
    upload.setSizeMax(maxUploadSize);
    try {
        return upload.getItemIterator(request);
    } catch (SizeLimitExceededException ex) {
        throw new SLException(MessageFormat.format(Messages.MAX_UPLOAD_SIZE_EXCEEDED, maxUploadSize));
    }
}
 
Example 21
public void handleFile(HttpServletRequest req) throws FileUploadException {
    ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
    List<FileItem> fileItems = upload.parseRequest(req);

    for (FileItem item : fileItems) {
        System.out.println("Saving " + item.getName() + "...");
    }
}
 
Example 22
@Override
public MultiValueMap<String, ?> read(Class<? extends MultiValueMap<String, ?>> clazz,
        HttpServletRequest request) throws IOException, HttpMessageNotReadableException {
    
    @SuppressWarnings("unchecked")
    MultiValueMap<String, Object> result = ServletUtils.extractUrlParams(request);
    
    if (ServletFileUpload.isMultipartContent(request)) {
        DiskFileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload fileUpload = new ServletFileUpload(factory);
        try {
            List<FileItem> fileItems = fileUpload.parseRequest(request);
            for (FileItem fileItem : fileItems) {
                if (fileItem.isFormField()) {
                    result.add(fileItem.getFieldName(), fileItem.getString(this.charset.name()));
                } else {
                    if (isImageMediaType(fileItem.getContentType())) {
                        result.add(fileItem.getFieldName(), new CommonsImageMultipartFile(fileItem));
                    } else {
                        result.add(fileItem.getFieldName(), new CommonsMultipartFile(fileItem));
                    }
                }
            }
        } catch (FileUploadException e) {
            logger.error("File upload failed", e);
        }
    }
    return result;
}
 
Example 23
Source Project: carbon-identity-framework   Source File: SecurityUIUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static List parseRequest(ServletRequestContext requestContext)
        throws FileUploadException {

    FileItemFactory factory = new DiskFileItemFactory();
    ServletFileUpload upload = new ServletFileUpload(factory);
    return upload.parseRequest(requestContext);
}
 
Example 24
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	assertTrue(ServletFileUpload.isMultipartContent(req));
	FileItemFactory factory = new DiskFileItemFactory();
	ServletFileUpload upload = new ServletFileUpload(factory);
	try {
		List<FileItem> items = upload.parseRequest(req);
		assertEquals(4, items.size());
		FileItem item = items.get(0);
		assertTrue(item.isFormField());
		assertEquals("name 1", item.getFieldName());
		assertEquals("value 1", item.getString());

		item = items.get(1);
		assertTrue(item.isFormField());
		assertEquals("name 2", item.getFieldName());
		assertEquals("value 2+1", item.getString());

		item = items.get(2);
		assertTrue(item.isFormField());
		assertEquals("name 2", item.getFieldName());
		assertEquals("value 2+2", item.getString());

		item = items.get(3);
		assertFalse(item.isFormField());
		assertEquals("logo", item.getFieldName());
		assertEquals("logo.jpg", item.getName());
		assertEquals("image/jpeg", item.getContentType());
	}
	catch (FileUploadException ex) {
		throw new ServletException(ex);
	}

}
 
Example 25
@SuppressFBWarnings({"FILE_UPLOAD_FILENAME", "WEAK_FILENAMEUTILS"})
protected Map<String, Part> getMultipartFormParametersMap() {
    if (multipartFormParameters != null) {
        return multipartFormParameters;
    }
    if (!ServletFileUpload.isMultipartContent(this)) { // isMultipartContent also checks the content type
        multipartFormParameters = new HashMap<>();
        return multipartFormParameters;
    }
    Timer.start("SERVLET_REQUEST_GET_MULTIPART_PARAMS");
    multipartFormParameters = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

    ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());

    try {
        List<FileItem> items = upload.parseRequest(this);
        for (FileItem item : items) {
            String fileName = FilenameUtils.getName(item.getName());
            AwsProxyRequestPart newPart = new AwsProxyRequestPart(item.get());
            newPart.setName(item.getFieldName());
            newPart.setSubmittedFileName(fileName);
            newPart.setContentType(item.getContentType());
            newPart.setSize(item.getSize());
            item.getHeaders().getHeaderNames().forEachRemaining(h -> {
                newPart.addHeader(h, item.getHeaders().getHeader(h));
            });

            multipartFormParameters.put(item.getFieldName(), newPart);
        }
    } catch (FileUploadException e) {
        Timer.stop("SERVLET_REQUEST_GET_MULTIPART_PARAMS");
        log.error("Could not read multipart upload file", e);
    }
    Timer.stop("SERVLET_REQUEST_GET_MULTIPART_PARAMS");
    return multipartFormParameters;
}
 
Example 26
@Test
public void handleValidatorMessageWhenFileUploadExceptionOccurs() throws Exception {
	when(event.getMethod()).thenReturn(uploadMethodController);

	when(observer.createServletFileUpload(config)).thenReturn(servletFileUpload);
	when(servletFileUpload.parseRequest(request)).thenThrow(new FileUploadException());
	
	observer.upload(event, request, config, validator);

	verify(validator).add(any(I18nMessage.class));
}
 
Example 27
@Override
public Iterator<PartPayload> iterator() {
  try {
    final FileItemIterator itemIterator = new ServletFileUpload().getItemIterator(httpRequest);
    return new PayloadIterator(itemIterator);
  }
  catch (FileUploadException | IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 28
@Override
public boolean hasNext() {
  try {
    return itemIterator.hasNext();
  }
  catch (FileUploadException | IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 29
@Override
public PartPayload next() {
  try {
    return new FileItemStreamPayload(itemIterator.next());
  }
  catch (FileUploadException | IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example 30
Source Project: nexus-public   Source File: UploadManagerImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private ComponentUpload create(final Repository repository, final HttpServletRequest request)
    throws IOException
{
  try {
    BlobStoreMultipartForm multipartForm = multipartHelper.parse(repository, request);
    return ComponentUploadUtils.createComponentUpload(repository.getFormat().getValue(), multipartForm);
  }
  catch (FileUploadException e) {
    throw new IOException(e);
  }
}