Example usage for org.apache.commons.fileupload FileUpload getSizeMax

List of usage examples for org.apache.commons.fileupload FileUpload getSizeMax

Introduction

In this page you can find the example usage for org.apache.commons.fileupload FileUpload getSizeMax.

Prototype

public long getSizeMax() 

Source Link

Document

Returns the maximum allowed upload size.

Usage

From source file:com.asual.summer.core.spring.RequestMultipartResolver.java

protected FileUpload prepareFileUpload(String encoding) {
    FileUpload fileUpload = getFileUpload();
    FileUpload actualFileUpload = fileUpload;
    if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) {
        actualFileUpload = newFileUpload(new StreamFileItemFactory());
        actualFileUpload.setSizeMax(fileUpload.getSizeMax());
        actualFileUpload.setHeaderEncoding(encoding);
    }//from  w w w  . j  a va2s  .co m
    return actualFileUpload;
}

From source file:com.hillert.upload.web.ajax.AjaxFileUploadMultipartResolver.java

public MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload1 = prepareFileUpload(encoding); //renamed fileUpload to fileUpload1

    // Beginn of added code
    UploadListener listener = new UploadListener(request, 30);
    FileItemFactory factory = new MonitoredDiskFileItemFactory(listener);
    ServletFileUpload fileUpload = new ServletFileUpload(factory);
    fileUpload.setSizeMax(fileUpload1.getSizeMax());
    fileUpload.setHeaderEncoding(fileUpload1.getHeaderEncoding());
    //end of added code

    try {/*from w ww. jav a2  s  .c  om*/
        List fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
        MultipartParsingResult parsingResult = parseFileItems(fileItems, encoding);
        return new DefaultMultipartHttpServletRequest(request, parsingResult.getMultipartFiles(),
                parsingResult.getMultipartParameters());
    } catch (FileUploadBase.SizeLimitExceededException ex) {
        throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    } catch (FileUploadException ex) {
        throw new MultipartException("Could not parse multipart servlet request", ex);
    }
}

From source file:cn.clxy.studio.common.web.multipart.GMultipartResolver.java

/**
 * Parse the given servlet request, resolving its multipart elements.
 *
 * @param request the request to parse//from  w  w  w.j  a va  2 s . co m
 * @return the parsing result
 * @throws MultipartException if multipart resolution failed.
 */
protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload = prepareFileUpload(encoding);
    try {
        List<FileItem> fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
        return parseFileItems(fileItems, encoding);
    } catch (FileUploadBase.SizeLimitExceededException ex) {
        throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    } catch (FileUploadException ex) {
        throw new MultipartException("Could not parse multipart servlet request", ex);
    }
}

From source file:ex.fileupload.spring.GMultipartResolver.java

/**
 * Parse the given servlet request, resolving its multipart elements.
 * //from   w w  w.j  a  v  a2s  .  c o m
 * @param request
 *            the request to parse
 * @return the parsing result
 * @throws MultipartException
 *             if multipart resolution failed.
 */
@SuppressWarnings("unchecked")
protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload = prepareFileUpload(encoding);
    try {
        List<FileItem> fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
        return parseFileItems(fileItems, encoding);
    } catch (FileUploadBase.SizeLimitExceededException ex) {
        throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    } catch (FileUploadException ex) {
        throw new MultipartException("Could not parse multipart servlet request", ex);
    }
}

From source file:de.uhh.l2g.upload.MyCommonsFileUploadSupport.java

/**
 * Prepare file upload.//from  w  w w .  j av a2  s  . c o m
 *
 * @param encoding the encoding
 * @return the file upload
 */
@Override
protected FileUpload prepareFileUpload(String encoding) {
    FileUpload fileUpload = getFileUpload();
    FileUpload actualFileUpload = fileUpload;

    // Use new temporary FileUpload instance if the request specifies
    // its own encoding that does not match the default encoding.
    if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) {
        actualFileUpload = newFileUpload(getFileItemFactory());
        actualFileUpload.setSizeMax(fileUpload.getSizeMax());
        actualFileUpload.setHeaderEncoding(encoding);
    }

    return actualFileUpload;
}

From source file:de.uhh.l2g.upload.MyCommonsPortletMultipartResolver.java

/**
 * Prepare file upload./*from  www .  j a  va 2s  .  com*/
 *
 * @param encoding the encoding
 * @return the file upload
 */
@Override
protected FileUpload prepareFileUpload(String encoding) {
    FileUpload fileUpload = getFileUpload();
    FileUpload actualFileUpload = fileUpload;
    // Use new temporary FileUpload instance if the request specifies
    // its own encoding that does not match the default encoding.
    if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) {
        actualFileUpload = newFileUpload(getFileItemFactory());
        actualFileUpload.setSizeMax(fileUpload.getSizeMax());
        actualFileUpload.setHeaderEncoding(encoding);
    }

    return actualFileUpload;
}

From source file:com.ms.commons.summer.web.multipart.CommonsMultipartEngancedResolver.java

@SuppressWarnings("all")
protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload = prepareFileUpload(encoding);
    try {/*from  ww  w . j  ava  2s  . com*/
        List fileItems = ((ServletFileUpload) fileUpload).parseRequest(request);
        return parseFileItems(fileItems, encoding);
    } catch (FileUploadBase.SizeLimitExceededException ex) {
        throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    } catch (FileUploadException ex) {
        throw new MultipartException("Could not parse multipart servlet request", ex);
    }
}

From source file:de.uhh.l2g.upload.MyCommonsPortletMultipartResolver.java

/**
 * Parses the request./*from www. j a  v a  2s  .  c  o m*/
 *
 * @param request the request
 * @return the multipart parsing result
 * @throws MultipartException the multipart exception
 */
@Override
protected MultipartParsingResult parseRequest(ActionRequest request) throws MultipartException {

    Integer userId = new Integer(request.getRemoteUser());
    Integer videoId = new Integer(request.getParameter("videoId"));
    long contentLength = request.getContentLength();
    ((UploadDao) getDaoBeanFactory().getBean("uploadDao")).create(userId, contentLength);

    String encoding = determineEncoding(request);
    FileUpload fileUpload = this.prepareFileUpload(encoding);

    try {
        PortletFileUpload pfu = ((PortletFileUpload) fileUpload);
        FileUploadProgressListener fupl = new FileUploadProgressListener(videoId, contentLength);
        pfu.setProgressListener(fupl);
        List<?> fileItems = pfu.parseRequest(request);

        return parseFileItems(fileItems, encoding);
    } catch (FileUploadBase.SizeLimitExceededException ex) {
        throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    } catch (FileUploadException ex) {
        throw new MultipartException("Could not parse multipart portlet request", ex);
    }

}

From source file:cn.clxy.studio.common.web.multipart.GFileUploadSupport.java

/**
 * Determine an appropriate FileUpload instance for the given encoding.
 * <p>/*from   ww  w . j  ava 2 s.  c o m*/
 * Default implementation returns the shared FileUpload instance if the encoding matches, else creates a new
 * FileUpload instance with the same configuration other than the desired encoding.
 *
 * @param encoding the character encoding to use
 * @return an appropriate FileUpload instance.
 */
protected FileUpload prepareFileUpload(String encoding) {
    FileUpload fileUpload = getFileUpload();
    FileUpload actualFileUpload = fileUpload;

    // Use new temporary FileUpload instance if the request specifies
    // its own encoding that does not match the default encoding.
    if (encoding != null && !encoding.equals(fileUpload.getHeaderEncoding())) {
        actualFileUpload = newFileUpload(getFileItemFactory());
        actualFileUpload.setSizeMax(fileUpload.getSizeMax());
        actualFileUpload.setHeaderEncoding(encoding);
    }

    return actualFileUpload;
}

From source file:org.jasig.springframework.web.portlet.upload.CommonsPortlet2MultipartResolver.java

protected MultipartParsingResult parseRequest(ResourceRequest request) throws MultipartException {
    String encoding = determineEncoding(request);
    FileUpload fileUpload = prepareFileUpload(encoding);
    try {/*  w  ww .  j av  a 2 s .  com*/
        @SuppressWarnings("unchecked")
        List<FileItem> fileItems = ((Portlet2FileUpload) fileUpload).parseRequest(request);
        return parseFileItems(fileItems, encoding);
    } catch (FileUploadBase.SizeLimitExceededException ex) {
        throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex);
    } catch (FileUploadException ex) {
        throw new MultipartException("Could not parse multipart portlet request", ex);
    }
}