java-helidon.server.libraries.se.formParamsFunctions.mustache Maven / Gradle / Ivy
private void processNonFileFormField(String name, Map> nonFileFormContent, ReadableBodyPart part) {
List content = nonFileFormContent.computeIfAbsent(name, key -> new ArrayList<>());
part.content().as(String.class).thenAccept(content::add);
}
private void processFileFormField(String name, Map> fileFormContent, ReadableBodyPart part) {
List content = fileFormContent.computeIfAbsent(name, key -> new ArrayList<>());
part.content().map(DataChunk::bytes)
.collect(ByteArrayOutputStream::new, (stream, bytes) -> {
try {
stream.write(bytes);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
})
.thenAccept(byteStream -> content.add(new ByteArrayInputStream(byteStream.toByteArray())));
}