【发布时间】:2021-12-05 13:38:56
【问题描述】:
我正在下载如下文件:
private File downloadAndReturnFile(String fileId, String destination) {
log.info("Downloading file.. " + fileId);
Path path = Paths.get(destination);
Flux<DataBuffer> dataBuffer = webClient.get().uri("/the/download/uri/" + fileId + "").retrieve()
.bodyToFlux(DataBuffer.class)
.doOnComplete(() -> log.info("{}", fileId + " - File downloaded successfully"));
//DataBufferUtils.write(dataBuffer, path, StandardOpenOption.CREATE).share().block();
return ???? // What should I do here to return above DataBuffer as file?
}
如何将 dataBuffer 作为文件返回?或者,如何将此 dataBuffer 转换为 File 对象?
【问题讨论】:
标签: spring spring-boot spring-webflux project-reactor