我想使用spring webflux以反应方式流式传输文件 我的端点应该如何更具体地说明对象的类型是什么?
@GetMapping("/file")
Flux<???> file() {
//Read file content into this ??? thing .
}
答案 0 :(得分:2)
您可以像这样返回Resource
个实例:
@GetMapping("/file")
Mono<Resource> file() {
//Create a ClassPathResource, for example
}
请注意,这会自动支持字节范围HTTP请求。