使用ReactiveGridFsTemplate SpringWebFlux在mongodb中存储base64映像
以前,我可以使用GridFsTemplate存储base64图像,如下所示使用ReactiveGridFsTemplate SpringWebFlux在mongodb中存储base64映像,spring,spring-boot,kotlin,spring-webflux,spring-mongodb,Spring,Spring Boot,Kotlin,Spring Webflux,Spring Mongodb,以前,我可以使用GridFsTemplate存储base64图像,如下所示 val imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary("base64 image string") gridFsTemplate.store(ByteArrayInputStream(imageBytes), "imagename") 但是,ReactiveGridFsTemplate的store()函数接受类型为Flux的参数。如何将b
val imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary("base64 image string")
gridFsTemplate.store(ByteArrayInputStream(imageBytes), "imagename")
但是,ReactiveGridFsTemplate的store()函数接受类型为
Flux
的参数。如何将base64映像转换为该类型?我相信您可以使用AsyncStreamHelper.toAsyncInputStream将base64作为字节数组
我现在正在打电话,所以我不能写一个例子,但是你可以在这里检查这个类的第二个最后一个方法: