ImmutableMultimap.Builder<String, Upload> originPartMultiMapBuilder = ImmutableMultimap.builder();
ImmutableSet.Builder<Upload> partBuilder = ImmutableSet.builder();
Iterator<Part> iterator = parts.iterator();
while (iterator.hasNext() && (keyCount++) < maxFormKeys) {
Part part = iterator.next();
if (part == null)
continue;
MultiPartInputStreamParser.MultiPart mp = (MultiPartInputStreamParser.MultiPart) part;
Upload upload = wrapPart(part, mp.getContentDispositionFilename());
originPartMultiMapBuilder.put(part.getName(), upload);
if (mp.getFile() != null) {
partMultiMapBuilder.put(part.getName(), upload);
partBuilder.add(upload);
} else {
String value = CharStreams.toString(
new InputStreamReader(part.getInputStream(), Charsets.UTF_8));
formMultiMapBuildBuilder.put(part.getName(), value);
}
}
this.forms = NullToEmptyMap.safeWrapper(
formMultiMapBuildBuilder.build().asMap()