WebClient如何实现零拷贝上传下载?
How to perform a zero-copy upload and download with WebClient?
您可以使用 org.springframework.web.reactive.function.client.WebClient
使用 Spring 5 WebFlux 执行零拷贝上传和下载吗?
没错,从基于文件的 Resource
.
发布数据时,目前支持零拷贝
所以下面看起来是正确的:
client.post()
.body(BodyInserters.fromResource(new FileSystemResource(new File("file.txt"))));
现在对于读取部分,Spring Framework 目前在读取端不支持零拷贝;您可以为此在 jira.spring.io 上创建增强问题。
您的代码示例应如下所示:
Flux<DataBuffer> incoming = client.post()
.retrieve().bodyToFlux(DataBuffer.class);
Mono<Void> writeOperation = DataBufferUtils.write(incoming, channel)
.map(DataBufferUtils::release)
.then();
// subscribe to the returned value, which will complete when writing is done
不幸的是,读取数据到DataBuffer
不会进行零拷贝,因为数据将被复制到内存中。我认为阅读方面不支持零拷贝,所以这可能是 https://jira.spring.io.
的增强请求
您可以使用 org.springframework.web.reactive.function.client.WebClient
使用 Spring 5 WebFlux 执行零拷贝上传和下载吗?
没错,从基于文件的 Resource
.
所以下面看起来是正确的:
client.post()
.body(BodyInserters.fromResource(new FileSystemResource(new File("file.txt"))));
现在对于读取部分,Spring Framework 目前在读取端不支持零拷贝;您可以为此在 jira.spring.io 上创建增强问题。
您的代码示例应如下所示:
Flux<DataBuffer> incoming = client.post()
.retrieve().bodyToFlux(DataBuffer.class);
Mono<Void> writeOperation = DataBufferUtils.write(incoming, channel)
.map(DataBufferUtils::release)
.then();
// subscribe to the returned value, which will complete when writing is done
不幸的是,读取数据到DataBuffer
不会进行零拷贝,因为数据将被复制到内存中。我认为阅读方面不支持零拷贝,所以这可能是 https://jira.spring.io.