WebFlux使用FilePart

参考:https://stackoverflow.com/questions/46460599

FilePart转byte[]

1
2
3
4
5
private byte[] filePart2ByteArray(FilePart filePart) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataBufferUtils.write(filePart.content(), byteArrayOutputStream).subscribe(DataBufferUtils.releaseConsumer());
return byteArrayOutputStream.toByteArray();
}

写入磁盘之前允许的最大内存量

1
2
3
4
spring:
webflux:
multipart:
max-in-memory-size: 10MB