Spring WebFlux Filepart DataBuffer 无法读取超过 108 行
Spring WebFlux Filepart DataBuffer cant read more than 108 lines
通过控制器下载文件后,服务出现错误。
文件中有 122 行,但它只读取了 108 行。
有人遇到过这样的问题吗?
Debug vars
109 line
Fileparser code
在这个方法中,filePartFlux是直接从controller层传过来的。然后我们平面映射 filePartFlux 并得到一个新的 Flux 流。
它可以帮助你通过使用此代码你可以上传任何文件并获得一个字符串
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);
}))
通过控制器下载文件后,服务出现错误。 文件中有 122 行,但它只读取了 108 行。 有人遇到过这样的问题吗?
Debug vars
109 line
Fileparser code
在这个方法中,filePartFlux是直接从controller层传过来的。然后我们平面映射 filePartFlux 并得到一个新的 Flux 流。 它可以帮助你通过使用此代码你可以上传任何文件并获得一个字符串
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);
}))