0

I have this controller :

@GetMapping(value = "/stream")
    public Flux<DataBuffer> stream() {  
            ...
            return webClient.get().uri(builder.buildAndExpand(parametres).toUriString())
                .header(HttpHeaders.CONTENT_TYPE, TEXT_CSV).retrieve().bodyToFlux(DataBuffer.class);
        }
    }

When i called this endpoint with PostMan, i have this reponse :

[
    {
        "nativeBuffer": {
            "direct": true,
            "readOnly": false,
            "contiguous": true,
            "readable": true,
            "writable": false
        },
        "allocated": true
    },
...

My question is, how can i consume this endoint with webclient to read the content of flux. Or perhaps, the controller is wrong ?

I tried this, but it's don't work :

 Flux<DataBuffer> fluxDataBuffer= webClient.get()
                .uri("http://localhost:8080/stream")
                .retrieve()
                .bodyToFlux(DataBuffer.class);

DataBufferUtils.write(fluxDataBuffer, Paths.get("test.txt"),
                        StandardOpenOption.CREATE)
                .share().block();

Thanks for your help

Samshay
  • 123
  • 1
  • 2
  • 10
  • Can you include `DataBuffer` code? Thanks! – João Dias Jan 19 '22 at 14:18
  • Euh, DataBuffer is an interface of org.springframework.core.io.buffer https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/buffer/DataBuffer.html – Samshay Jan 19 '22 at 15:48

0 Answers0