api/src/main/java/com/google/apphosting/utils/servlet/ee10/ParseBlobUploadFilter.java [90:130]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    if (req.getHeader(UPLOAD_HEADER) != null) {
      Map<String, List<String>> blobKeys = new HashMap<>();
      Map<String, List<Map<String, String>>> blobInfos = new HashMap<>();
      Map<String, List<String>> otherParams = new HashMap<>();

      try {
        MimeMultipart multipart = MultipartMimeUtils.parseMultipartRequest(req);

        int parts = multipart.getCount();
        for (int i = 0; i < parts; i++) {
          BodyPart part = multipart.getBodyPart(i);
          String fieldName = MultipartMimeUtils.getFieldName(part);
          if (part.getFileName() != null) {
            ContentType contentType = new ContentType(part.getContentType());
            if ("message/external-body".equals(contentType.getBaseType())) {
              String blobKeyString = contentType.getParameter("blob-key");
              List<String> keys = blobKeys.computeIfAbsent(fieldName, k -> new ArrayList<>());
              keys.add(blobKeyString);
              List<Map<String, String>> infos =
                  blobInfos.computeIfAbsent(fieldName, k -> new ArrayList<>());
              infos.add(getInfoFromBody(MultipartMimeUtils.getTextContent(part), blobKeyString));
            }
          } else {
            List<String> values = otherParams.computeIfAbsent(fieldName, k -> new ArrayList<>());
            values.add(MultipartMimeUtils.getTextContent(part));
          }
        }
        req.setAttribute(UPLOADED_BLOBKEY_ATTR, blobKeys);
        req.setAttribute(UPLOADED_BLOBINFO_ATTR, blobInfos);
      } catch (MessagingException ex) {
        logger.log(Level.WARNING, "Could not parse multipart message:", ex);
      }

      chain.doFilter(new ParameterServletWrapper(request, otherParams), response);
    } else {
      chain.doFilter(request, response);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



api/src/main/java/com/google/apphosting/utils/servlet/ParseBlobUploadFilter.java [90:130]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    if (req.getHeader(UPLOAD_HEADER) != null) {
      Map<String, List<String>> blobKeys = new HashMap<>();
      Map<String, List<Map<String, String>>> blobInfos = new HashMap<>();
      Map<String, List<String>> otherParams = new HashMap<>();

      try {
        MimeMultipart multipart = MultipartMimeUtils.parseMultipartRequest(req);

        int parts = multipart.getCount();
        for (int i = 0; i < parts; i++) {
          BodyPart part = multipart.getBodyPart(i);
          String fieldName = MultipartMimeUtils.getFieldName(part);
          if (part.getFileName() != null) {
            ContentType contentType = new ContentType(part.getContentType());
            if ("message/external-body".equals(contentType.getBaseType())) {
              String blobKeyString = contentType.getParameter("blob-key");
              List<String> keys = blobKeys.computeIfAbsent(fieldName, k -> new ArrayList<>());
              keys.add(blobKeyString);
              List<Map<String, String>> infos =
                  blobInfos.computeIfAbsent(fieldName, k -> new ArrayList<>());
              infos.add(getInfoFromBody(MultipartMimeUtils.getTextContent(part), blobKeyString));
            }
          } else {
            List<String> values = otherParams.computeIfAbsent(fieldName, k -> new ArrayList<>());
            values.add(MultipartMimeUtils.getTextContent(part));
          }
        }
        req.setAttribute(UPLOADED_BLOBKEY_ATTR, blobKeys);
        req.setAttribute(UPLOADED_BLOBINFO_ATTR, blobInfos);
      } catch (MessagingException ex) {
        logger.log(Level.WARNING, "Could not parse multipart message:", ex);
      }

      chain.doFilter(new ParameterServletWrapper(request, otherParams), response);
    } else {
      chain.doFilter(request, response);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



