private void prepareDestination()

in teamcity-s3-sdk/src/main/java/jetbrains/buildServer/artifacts/s3/publish/S3RegularFileUploader.java [134:156]


  private void prepareDestination(final String bucketName,
                                  final Map<String, String> params) throws Throwable {
    if (isDestinationPrepared) return;
    try {
      if ("US".equals(params.get(AWSCommonParams.REGION_NAME_PARAM))) {
        params.put(AWSCommonParams.REGION_NAME_PARAM, "us-east-1");
      }
    } catch (Exception e) {
      LOG.infoAndDebugDetails("Attempt to correct aws region from US to us-east-1 failed", e);
    }

    S3Util.withS3ClientShuttingDownImmediately(params, (S3Util.WithS3<Void, Throwable>)s3Client -> {
      try {
        s3Client.headBucket(b -> b.bucket(bucketName));
        isDestinationPrepared = true;
        return null;
      } catch (NoSuchBucketException e) {
        throw new FileUploadFailedException("Target S3 artifact bucket " + bucketName + " doesn't exist", false);
      } catch (S3Exception e) {
        throw new FileUploadFailedException("Target S3 artifact bucket " + bucketName + " is not accessable", false, e);
      }
    });
  }