Issue
After downloading the file through the controller, an error occurs in the service. There are 122 lines in the file, but it only reads 108. Has anyone encountered such a problem?
Solution
In this method, the filePartFlux is directly passed from the controller layer. Then we flat map filePartFlux and get a new Flux stream. It may help you by using this code you can upload any file and get a string
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);
}))
Answered By - Ankit Srivastava