Search in sources :

Example 1 with PJProgressListener

use of com.ngtesting.platform.servlet.PJProgressListener in project ngtesting-platform by aaronchen2k.

the class PJCommonsMultipartResolver method newFileUpload.

protected FileUpload newFileUpload(FileItemFactory fileItemFactory) {
    ServletFileUpload upload = new ServletFileUpload(fileItemFactory);
    upload.setSizeMax(-1);
    if (request != null) {
        HttpSession session = request.getSession();
        PJProgressListener uploadProgressListener = new PJProgressListener(request);
        upload.setProgressListener(uploadProgressListener);
    }
    return upload;
}
Also used : ServletFileUpload(org.apache.commons.fileupload.servlet.ServletFileUpload) HttpSession(javax.servlet.http.HttpSession) PJProgressListener(com.ngtesting.platform.servlet.PJProgressListener)

Example 2 with PJProgressListener

use of com.ngtesting.platform.servlet.PJProgressListener in project ngtesting-platform by aaronchen2k.

the class PJCommonsMultipartResolver method parseRequest.

@Override
public MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException {
    String encoding = "utf-8";
    FileUpload fileUpload = prepareFileUpload(encoding);
    PJProgressListener uploadProgressListener = new PJProgressListener(request);
    fileUpload.setProgressListener(uploadProgressListener);
    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);
    }
}
Also used : MaxUploadSizeExceededException(org.springframework.web.multipart.MaxUploadSizeExceededException) ServletFileUpload(org.apache.commons.fileupload.servlet.ServletFileUpload) MultipartException(org.springframework.web.multipart.MultipartException) PJProgressListener(com.ngtesting.platform.servlet.PJProgressListener) ServletFileUpload(org.apache.commons.fileupload.servlet.ServletFileUpload)

Aggregations

PJProgressListener (com.ngtesting.platform.servlet.PJProgressListener)2 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)2 HttpSession (javax.servlet.http.HttpSession)1 MaxUploadSizeExceededException (org.springframework.web.multipart.MaxUploadSizeExceededException)1 MultipartException (org.springframework.web.multipart.MultipartException)1