/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param request The servlet request to be parsed. * * @return A list of <code>FileItem</code> instances parsed from the * request, in the order that they were transmitted. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. */ @Override public List<FileItem> parseRequest(HttpServletRequest request) throws FileUploadException { return parseRequest(new ServletRequestContext(request)); }
/** * Utility method that determines whether the request contains multipart * content. * * @param request The servlet request to be evaluated. Must be non-null. * * @return <code>true</code> if the request is multipart; * <code>false</code> otherwise. */ public static final boolean isMultipartContent( HttpServletRequest request) { if (!POST_METHOD.equalsIgnoreCase(request.getMethod())) { return false; } return FileUploadBase.isMultipartContent(new ServletRequestContext(request)); }
/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param request The servlet request to be parsed. * * @return A map of <code>FileItem</code> instances parsed from the request. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. * * @since 1.3 */ public Map<String, List<FileItem>> parseParameterMap(HttpServletRequest request) throws FileUploadException { return parseParameterMap(new ServletRequestContext(request)); }
/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param req The servlet request to be parsed. * * @return A list of <code>FileItem</code> instances parsed from the * request, in the order that they were transmitted. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. * * @deprecated 1.1 Use {@link ServletFileUpload#parseRequest(HttpServletRequest)} instead. */ @Deprecated public List<FileItem> parseRequest(HttpServletRequest req) throws FileUploadException { return parseRequest(new ServletRequestContext(req)); }
/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param request The servlet request to be parsed. * * @return An iterator to instances of <code>FileItemStream</code> * parsed from the request, in the order that they were * transmitted. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. * @throws IOException An I/O error occurred. This may be a network * error while communicating with the client or a problem while * storing the uploaded content. */ public FileItemIterator getItemIterator(HttpServletRequest request) throws FileUploadException, IOException { return super.getItemIterator(new ServletRequestContext(request)); }
public static List<FileItem> parseUpload(FileUpload upload, byte[] bytes, String contentType) throws FileUploadException { final HttpServletRequest request = new MockHttpServletRequest(bytes, contentType); List<FileItem> fileItems = upload.parseRequest(new ServletRequestContext(request)); return fileItems; }
private List<FileItem> parseUpload(InputStream pStream, int pLength) throws FileUploadException { String contentType = "multipart/form-data; boundary=---1234"; FileUploadBase upload = new ServletFileUpload(); upload.setFileItemFactory(new DiskFileItemFactory()); HttpServletRequest request = new MockHttpServletRequest(pStream, pLength, contentType); List<FileItem> fileItems = upload.parseRequest(new ServletRequestContext(request)); return fileItems; }
private FileItemIterator parseUpload(int pLength, InputStream pStream) throws FileUploadException, IOException { String contentType = "multipart/form-data; boundary=---1234"; FileUploadBase upload = new ServletFileUpload(); upload.setFileItemFactory(new DiskFileItemFactory()); HttpServletRequest request = new MockHttpServletRequest(pStream, pLength, contentType); return upload.getItemIterator(new ServletRequestContext(request)); }
public MultipartForm getForm(HttpServletRequest request) { return getForm(new ServletRequestContext(request)); }
RequestContext requestContext = new ServletRequestContext(httpRequest); if (!ServletFileUpload.isMultipartContent(requestContext)) { throw new ServletException("The request is not a valid multipart/form-data upload request");
public HttpFileUploadRequestWrapper(HttpServletRequest pRequest, File pUploadDir, long pMaxSize) throws ServletException { super(pRequest); DiskFileItemFactory factory = new DiskFileItemFactory( 128 * 1024, // 128 KByte new File(pUploadDir.getAbsolutePath()) ); FileUpload upload = new FileUpload(factory); upload.setSizeMax(pMaxSize); // TODO: Defer request parsing?? try { //noinspection unchecked List<FileItem> items = upload.parseRequest(new ServletRequestContext(pRequest)); for (FileItem item : items) { if (item.isFormField()) { processFormField(item.getFieldName(), item.getString()); } else { processeFile(item); } } } catch (FileUploadBase.SizeLimitExceededException e) { throw new FileSizeExceededException(e); } catch (org.apache.commons.fileupload.FileUploadException e) { throw new FileUploadException(e); } }
/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param request The servlet request to be parsed. * * @return A list of <code>FileItem</code> instances parsed from the * request, in the order that they were transmitted. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. */ @Override public List<FileItem> parseRequest(HttpServletRequest request) throws FileUploadException { return parseRequest(new ServletRequestContext(request)); }
/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param request The servlet request to be parsed. * * @return A list of <code>FileItem</code> instances parsed from the * request, in the order that they were transmitted. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. */ public List /* FileItem */ parseRequest(HttpServletRequest request) throws FileUploadException { return parseRequest(new ServletRequestContext(request)); }
public FormData(HttpServletRequest request) { this.request = request; isMultipart = getIsMultipartContent(); if (isMultipart) { ctx = new ServletRequestContext(request); } }
/** Returns whether the request contains multipart content. */ public static final boolean isMultipartContent(HttpServletRequest request) { return "post".equals(request.getMethod().toLowerCase(java.util.Locale.ENGLISH)) && FileUploadBase.isMultipartContent(new ServletRequestContext(request)); }
/** Returns whether the request contains multipart content. */ public static final boolean isMultipartContent(HttpServletRequest request) { return "post".equals(request.getMethod().toLowerCase(java.util.Locale.ENGLISH)) && FileUploadBase.isMultipartContent(new ServletRequestContext(request)); }
/** * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> * compliant <code>multipart/form-data</code> stream. * * @param req The servlet request to be parsed. * * @return A list of <code>FileItem</code> instances parsed from the * request, in the order that they were transmitted. * * @throws FileUploadException if there are problems reading/parsing * the request or storing files. * * @deprecated Use the method in <code>ServletFileUpload</code> instead. */ public List /* FileItem */ parseRequest(HttpServletRequest req) throws FileUploadException { return parseRequest(new ServletRequestContext(req)); }
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) req; HttpServletResponse httpResponse = (HttpServletResponse) res; if (ServletFileUpload.isMultipartContent(new ServletRequestContext( httpRequest))) { httpRequest = new MultipartServletRequest(httpRequest); } chain.doFilter(httpRequest, httpResponse); } }
@Override public boolean isMultipart(HttpServletRequest request) { // support HTTP PUT operation String method = request.getMethod().toLowerCase(); if (S.neq("post", method) && S.neq("put", method)) { return false; } return FileUploadBase.isMultipartContent(new ServletRequestContext(request)); } }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { if (ServletFileUpload.isMultipartContent(new ServletRequestContext(req))) { handleCertificateUpload(req, res); } else { handleCertificateManagement(req, res); } }