@NotNull @Override public String getPreSignedUrl(@NotNull HttpMethod httpMethod, @NotNull String bucketName, @NotNull String objectKey, @NotNull Map<String, String> params) throws IOException { try { final Callable<String> resolver = () -> S3Util.withS3Client(ParamUtil.putSslValues(myServerPaths, params), client -> { final GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucketName, objectKey, httpMethod) .withExpiration(new Date(System.currentTimeMillis() + getUrlLifetimeSec() * 1000)); return client.generatePresignedUrl(request).toString(); }); if (httpMethod == HttpMethod.GET) { return TeamCityProperties.getBoolean(TEAMCITY_S3_PRESIGNURL_GET_CACHE_ENABLED) ? myGetLinksCache.get(getCacheIdentity(params, objectKey, bucketName), resolver) : resolver.call(); } else { return resolver.call(); } } catch (Exception e) { final Throwable cause = e.getCause(); final AWSException awsException = cause != null ? new AWSException(cause) : new AWSException(e); final String details = awsException.getDetails(); if (StringUtil.isNotEmpty(details)) { final String message = awsException.getMessage() + details; LOG.warn(message); } throw new IOException(String.format( "Failed to create pre-signed URL to %s artifact '%s' in bucket '%s': %s", httpMethod.name().toLowerCase(), objectKey, bucketName, awsException.getMessage() ), awsException); } }