【发布时间】:2018-03-22 10:30:04
【问题描述】:
我有一个旧库,我必须使用它来检索文件。这个遗留库不会在 InputStream 中返回,就像您通常期望的那样阅读内容,但它希望它被传递一个开放的 OutputStream,它可以写入。
我必须编写一个 Webflux REST 服务,将这个 OutputStream 写入 org.springframework.web.reactive.function.server.ServerResponse 主体。
legacyLib.BlobRead(outputStream); // writes the stream to an outputstream, that has to be provided by me, and somehow has to end up in the ServerResponse
由于我想将 Stream 直接传递给 ServerResponse,我可能必须做这样的事情,对吧?
ServerResponse.ok().body(magicOutpuStreamToFluxConverter(), DataBuffer.class);
【问题讨论】:
-
您能否修改您的问题以使这段代码 sn-p 更清晰一些?没有类型的伪代码使您更难理解哪一部分是您从库中获得的实际类型,哪一部分是您希望看到的解决方案的伪代码。
标签: spring-webflux