Skip to content

Instantly share code, notes, and snippets.

@eaiman-shoshi
Last active March 29, 2020 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eaiman-shoshi/a2122cf37624a1d2961f79551ebb86a0 to your computer and use it in GitHub Desktop.
Save eaiman-shoshi/a2122cf37624a1d2961f79551ebb86a0 to your computer and use it in GitHub Desktop.
public Flux<String> getLines(Flux<FilePart> filePartFlux) {
return filePartFlux.flatMap(filePart ->
filePart.content().map(dataBuffer -> {
byte[] bytes = new byte[dataBuffer.readableByteCount()];
dataBuffer.read(bytes);
DataBufferUtils.release(dataBuffer);
return new String(bytes, StandardCharsets.UTF_8);
})
.map(this::processAndGetLinesAsList)
.flatMapIterable(Function.identity());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment