/** * 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)); }
@Override public String getCharacterEncoding() { String charset = super.getCharacterEncoding(); if (charset == null) { charset = DEFAULT_CHARSET; } return charset; } }
/** * Returns a string representation of this object. * * @return a string representation of this object. */ @Override public String toString() { return format("ContentLength=%s, ContentType=%s", Long.valueOf(this.contentLength()), this.getContentType()); }
/** * Returns a string representation of this object. * * @return a string representation of this object. */ public String toString() { return "ContentLength=" + this.getContentLength() + ", ContentType=" + this.getContentType(); } }
/** * 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)); }
@Override public String getCharacterEncoding() { String charset = super.getCharacterEncoding(); if (charset == null) { charset = DEFAULT_CHARSET; } return charset; } }
/** * Returns a string representation of this object. * * @return a string representation of this object. */ @Override public String toString() { return format("ContentLength=%s, ContentType=%s", Long.valueOf(this.contentLength()), this.getContentType()); }
/** * 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)); }
public String getCharacterEncoding() { String charset = super.getCharacterEncoding(); if (charset == null) { charset = DEFAULT_CHARSET; } return charset; }
/** * 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)); }
public String getCharacterEncoding() { String charset = super.getCharacterEncoding(); if (charset == null) { charset = DEFAULT_CHARSET; } return charset; }
/** * 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)); }
@Override public String getCharacterEncoding() { String charset = super.getCharacterEncoding(); if (charset == null) { charset = DEFAULT_CHARSET; } return charset; } }
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)); }