Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Map<String, String> vars = new HashMap<>();
- vars.put("uuid", attachment.getUuid().toString());
- final ResponseSpec response = getWebClient().get().uri(endpoint, vars).header(HttpHeaders.AUTHORIZATION, jsonWebToken).retrieve();
- try (
- WritableByteChannel channel = Channels.newChannel(new FileOutputStream(localFile));) {
- Mono<Void> writeOperation = DataBufferUtils.write(response.bodyToFlux(DataBuffer.class), channel).map(DataBufferUtils::release).then();
- writeOperation.block();
- }
- } catch (WebClientResponseException e) {
- logger.warn("Download attachment returned with status code {}", e.getStatusCode());
- logger.debug("Call failed with exception : ", e);
- if (logger.isDebugEnabled()) {
- logger.debug("Response was [{}]", e.getResponseBodyAsString());
- }
- throw new IOException("Failed to download attachment : " + e.getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement