Guest User

Untitled

a guest
Jul 14th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. WebClient client = WebClient.builder()
  2. .clientConnector(new ReactorClientHttpConnector(httpClient1))
  3. .baseUrl(String.format(FILE_DOWNLOAD_PATH))
  4. .build();
  5. WebClient.RequestBodyUriSpec method = client.method(HttpMethod.GET);
  6. method.header("Authorization", "Bearer " + accessToken);
  7. final Flux<DataBuffer> dataBufferFlux = method.retrieve().bodyToFlux(DataBuffer.class);
  8. final Path path = FileSystems.getDefault().getPath("example" + new Random(200).nextInt() + ".zip");
  9. WritableByteChannel channel = Files.newByteChannel(path, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
  10. Mono<Path> then = DataBufferUtils.write(dataBufferFlux, channel)
  11. .map(DataBufferUtils::release)
  12. .then(Mono.just(path));
Advertisement
Add Comment
Please, Sign In to add comment