Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WebClient client = WebClient.builder()
- .clientConnector(new ReactorClientHttpConnector(httpClient1))
- .baseUrl(String.format(FILE_DOWNLOAD_PATH))
- .build();
- WebClient.RequestBodyUriSpec method = client.method(HttpMethod.GET);
- method.header("Authorization", "Bearer " + accessToken);
- final Flux<DataBuffer> dataBufferFlux = method.retrieve().bodyToFlux(DataBuffer.class);
- final Path path = FileSystems.getDefault().getPath("example" + new Random(200).nextInt() + ".zip");
- WritableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
- Mono<Path> then = DataBufferUtils.write(dataBufferFlux, channel)
- .map(DataBufferUtils::release)
- .then(Mono.just(path));
Advertisement
Add Comment
Please, Sign In to add comment