I want to get the byte content of the File. Here is my controller:
@PostMapping("/files")
@ResponseStatus(HttpStatus.OK)
public List<UserFilesResponse> uploadFile(@RequestPart("file") FilePart file) {
// I want to get the bytes[] content of my file. How can I do it please ??
}
As M. Deinum mentioned, you should use content
I would also recommend https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/buffer/DataBufferUtils.html#join-org.reactivestreams.Publisher-
DataBufferUtils.join(filePart.content())
.map(dataBuffer -> dataBuffer.asByteBuffer().array())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With