gpt4 book ai didi

spring-webflux - 如何使用 spring webflux 进行文件流传输

转载 作者:行者123 更新时间:2023-12-01 03:20:39 26 4
gpt4 key购买 nike

我想使用 spring webflux 以 react 方式流式传输文件。
我的端点应该看起来更具体什么是对象的类型?

@GetMapping("/file")
Flux<???> file() {
//Read file content into this ??? thing .
}

最佳答案

您可以返回 Resource像这样的例子:

@GetMapping("/file")
Mono<Resource> file() {
//Create a ClassPathResource, for example
}

请注意,这会自动支持字节范围 HTTP 请求。

关于spring-webflux - 如何使用 spring webflux 进行文件流传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45532254/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com