Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
moved getParts and getPart to AwsHttpServletRequest
  • Loading branch information
mbfreder committed Nov 3, 2023
commit 3b00e72f215059a2aefc2744a52b78ad845e0948
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,6 @@ public void logout() throws ServletException {
throw new UnsupportedOperationException();
}

@Override
public Collection<Part> getParts() throws IOException, ServletException {
List<Part> partList =
getMultipartFormParametersMap().values().stream()
.flatMap(List::stream)
.collect(Collectors.toList());
return partList;
}

@Override
public Part getPart(String s) throws IOException, ServletException {
// In case there's multiple files with the same fieldName, we return the first one in the list
List<Part> values = getMultipartFormParametersMap().get(s);
if (Objects.isNull(values)) {
return null;
}
return getMultipartFormParametersMap().get(s).get(0);
}

@Override
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) throws IOException, ServletException {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,27 @@ protected Map<String, List<String>> getFormUrlEncodedParametersMap() {
return urlEncodedFormParameters;
}

@Override
public Collection<Part> getParts()
throws IOException, ServletException {
List<Part> partList =
getMultipartFormParametersMap().values().stream()
.flatMap(List::stream)
.collect(Collectors.toList());
return partList;
}

@Override
public Part getPart(String s)
throws IOException, ServletException {
// In case there's multiple files with the same fieldName, we return the first one in the list
List<Part> values = getMultipartFormParametersMap().get(s);
if (Objects.isNull(values)) {
return null;
}
return getMultipartFormParametersMap().get(s).get(0);
}

@SuppressFBWarnings({"FILE_UPLOAD_FILENAME", "WEAK_FILENAMEUTILS"})
protected Map<String, List<Part>> getMultipartFormParametersMap() {
if (multipartFormParameters != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,30 +255,6 @@ public void logout()
throw new UnsupportedOperationException();
}


@Override
public Collection<Part> getParts()
throws IOException, ServletException {
List<Part> partList =
getMultipartFormParametersMap().values().stream()
.flatMap(List::stream)
.collect(Collectors.toList());
return partList;
}


@Override
public Part getPart(String s)
throws IOException, ServletException {
// In case there's multiple files with the same fieldName, we return the first one in the list
List<Part> values = getMultipartFormParametersMap().get(s);
if (Objects.isNull(values)) {
return null;
}
return getMultipartFormParametersMap().get(s).get(0);
}


@Override
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass)
throws IOException, ServletException {
Expand Down