java-helidon.server.libraries.se.formParamsFunctions.mustache Maven / Gradle / Ivy
private void processNonFileFormField(String name, Map> nonFileFormContent, Readable{{#x-helidon-v3}}Body{{/x-helidon-v3}}Part part) {
List content = nonFileFormContent.computeIfAbsent(name, key -> new ArrayList<>());
{{#x-helidon-v3}} part.content().as(String.class).thenAccept(content::add);
{{/x-helidon-v3}}
{{^x-helidon-v3}} content.add(part.as(String.class));
{{/x-helidon-v3}}
}
{{!
Helidon 4 changed ReadableBodyPart to ReadablePart and, for Helidon 4, we save the entire part (which can now include
the optional filename and part headers) as well as the InputStream instead of just the InputStream as in Helidon 3.
}}
private void processFileFormField(String name, Map> fileFormContent, Readable{{#x-helidon-v3}}Body{{/x-helidon-v3}}Part part) {
{{^x-helidon-v3}} {{/x-helidon-v3}}List<{{#x-helidon-v3}}InputStream{{/x-helidon-v3}}{{^x-helidon-v3}}ReadablePart{{/x-helidon-v3}}> content = fileFormContent.computeIfAbsent(name, key -> new ArrayList<>());
{{#x-helidon-v3}} 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())));
{{/x-helidon-v3}}{{!
}}{{^x-helidon-v3}} content.add(part);
{{/x-helidon-v3}}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy