/** * Utility method that determines whether the request contains multipart * content. * * @param request The portlet 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(ActionRequest request) { return FileUploadBase.isMultipartContent( new PortletRequestContext(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)); }
boolean successful = false; try { FileItemIterator iter = getItemIterator(ctx); FileItemFactory fac = getFileItemFactory(); if (fac == null) { throw new NullPointerException("No FileItemFactory has been set.");
/** * Retrieves the field name from the <code>Content-disposition</code> * header. * * @param headers A <code>Map</code> containing the HTTP request headers. * * @return The field name for the current <code>encapsulation</code>. * @deprecated 1.2.1 Use {@link #getFieldName(FileItemHeaders)}. */ @Deprecated protected String getFieldName(Map<String, String> headers) { return getFieldName(getHeader(headers, CONTENT_DISPOSITION)); }
/** * Retrieves the file name from the <code>Content-disposition</code> * header. * * @param headers A <code>Map</code> containing the HTTP request headers. * * @return The file name for the current <code>encapsulation</code>. * @deprecated 1.2.1 Use {@link #getFileName(FileItemHeaders)}. */ @Deprecated protected String getFileName(Map<String, String> headers) { return getFileName(getHeader(headers, CONTENT_DISPOSITION)); }
/** * Creates a new {@link FileItem} instance. * * @param headers A <code>Map</code> containing the HTTP request * headers. * @param isFormField Whether or not this item is a form field, as * opposed to a file. * * @return A newly created <code>FileItem</code> instance. * * @throws FileUploadException if an error occurs. * @deprecated 1.2 This method is no longer used in favour of * internally created instances of {@link FileItem}. */ @Deprecated protected FileItem createItem(Map<String, String> headers, boolean isFormField) throws FileUploadException { return getFileItemFactory().createItem(getFieldName(headers), getHeader(headers, CONTENT_TYPE), isFormField, getFileName(headers)); }
continue; FileItemHeaders headers = getParsedHeaders(multi.readHeaders()); if (currentFieldName == null) { String fieldName = getFieldName(headers); if (fieldName != null) { String subContentType = headers.getHeader(CONTENT_TYPE); currentFieldName = fieldName; byte[] subBoundary = getBoundary(subContentType); multi.setBoundary(subBoundary); skipPreamble = true; continue; String fileName = getFileName(headers); currentItem = new FileItemStreamImpl(fileName, fieldName, headers.getHeader(CONTENT_TYPE), String fileName = getFileName(headers); if (fileName != null) { currentItem = new FileItemStreamImpl(fileName,
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; }
upload.setHeaderEncoding(request.getCharacterEncoding()); upload.setSizeMax(getSizeMax(ac)); items = upload.parseRequest(request); } catch (DiskFileUpload.SizeLimitExceededException e) {
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)); }
/** * Retrieves the file name from the <code>Content-disposition</code> * header. * * @param headers The HTTP headers object. * * @return The file name for the current <code>encapsulation</code>. */ protected String getFileName(FileItemHeaders headers) { return getFileName(headers.getHeader(CONTENT_DISPOSITION)); }
/** * Retrieves the field name from the <code>Content-disposition</code> * header. * * @param headers A <code>Map</code> containing the HTTP request headers. * * @return The field name for the current <code>encapsulation</code>. */ protected String getFieldName(FileItemHeaders headers) { return getFieldName(headers.getHeader(CONTENT_DISPOSITION)); }
boundary = getBoundary(contentType); if (boundary == null) {
/** * Creates a new {@link FileItem} instance. * * @param headers A <code>Map</code> containing the HTTP request * headers. * @param isFormField Whether or not this item is a form field, as * opposed to a file. * * @return A newly created <code>FileItem</code> instance. * * @throws FileUploadException if an error occurs. * @deprecated This method is no longer used in favour of * internally created instances of {@link FileItem}. */ protected FileItem createItem(Map /* String, String */ headers, boolean isFormField) throws FileUploadException { return getFileItemFactory().createItem(getFieldName(headers), getHeader(headers, CONTENT_TYPE), isFormField, getFileName(headers)); }
continue; FileItemHeaders headers = getParsedHeaders(multi.readHeaders()); if (currentFieldName == null) { String fieldName = getFieldName(headers); if (fieldName != null) { String subContentType = headers.getHeader(CONTENT_TYPE); currentFieldName = fieldName; byte[] subBoundary = getBoundary(subContentType); multi.setBoundary(subBoundary); skipPreamble = true; continue; String fileName = getFileName(headers); currentItem = new FileItemStreamImpl(fileName, fieldName, headers.getHeader(CONTENT_TYPE), String fileName = getFileName(headers); if (fileName != null) { currentItem = new FileItemStreamImpl(fileName,
/** * Retrieves the field name from the <code>Content-disposition</code> * header. * * @param headers A <code>Map</code> containing the HTTP request headers. * * @return The field name for the current <code>encapsulation</code>. * @deprecated Use {@link #getFieldName(FileItemHeaders)}. */ protected String getFieldName(Map /* String, String */ headers) { return getFieldName(getHeader(headers, CONTENT_DISPOSITION)); }
/** * Retrieves the file name from the <code>Content-disposition</code> * header. * * @param headers A <code>Map</code> containing the HTTP request headers. * * @return The file name for the current <code>encapsulation</code>. * @deprecated Use {@link #getFileName(FileItemHeaders)}. */ protected String getFileName(Map /* String, String */ headers) { return getFileName(getHeader(headers, CONTENT_DISPOSITION)); }
/** * Retrieves the file name from the <code>Content-disposition</code> * header. * * @param headers The HTTP headers object. * * @return The file name for the current <code>encapsulation</code>. */ protected String getFileName(FileItemHeaders headers) { return getFileName(headers.getHeader(CONTENT_DISPOSITION)); }
/** * Retrieves the field name from the <code>Content-disposition</code> * header. * * @param headers A <code>Map</code> containing the HTTP request headers. * * @return The field name for the current <code>encapsulation</code>. */ protected String getFieldName(FileItemHeaders headers) { return getFieldName(headers.getHeader(CONTENT_DISPOSITION)); }
boundary = getBoundary(contentType); if (boundary == null) {