0

Previously, i was able to store a base64 image using GridFsTemplate as below.

val imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary("base64 image string")
gridFsTemplate.store(ByteArrayInputStream(imageBytes), "imagename")

However the store() function of ReactiveGridFsTemplate takes in a parameter which is of type Flux<DataBuffer>. How can i convert a base64 image to that type?

Nicodemus Ojwee
  • 744
  • 6
  • 12

1 Answers1

0

I believe you can use AsyncStreamHelper.toAsyncInputStream with the base64 as a byte array.

I'm on my phone right now so I can't write an example, but you can check the second last method of the class here: https://github.com/BayviewComputerClub/smoothie-web/blob/master/src/main/java/club/bayview/smoothieweb/repositories/TestDataRepository.java

espidev
  • 26
  • 3