private static BackupUploadService configureBackupUploadService()

in import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/ImportAdapter.java [232:255]


  private static BackupUploadService configureBackupUploadService(
      Flags flags, GoogleCredentials credentials) throws IOException {
    String uploadPath = flags.persistentFileStorageLocation;
    if (flags.useStowOverwrite
        && (uploadPath.isBlank() || flags.persistentFileUploadRetryAmount < 1)) {
      throw new IllegalArgumentException(
          "--stow_overwrite requires the use of --persistent_file_storage_location and"
              + " --persistent_file_upload_retry_amount >= 1");
    }
    if (!uploadPath.isBlank()) {
      final IBackupUploader backupUploader;
      if (uploadPath.startsWith(GCP_PATH_PREFIX)) {
        backupUploader = new GcpBackupUploader(uploadPath, flags.gcsBackupProjectId, credentials);
      } else {
        backupUploader = new LocalBackupUploader(uploadPath);
      }
      return new BackupUploadService(
          backupUploader,
          flags.persistentFileUploadRetryAmount,
          ImmutableList.copyOf(flags.httpErrorCodesToRetry),
          new DelayCalculator(flags.minUploadDelay, flags.maxWaitingTimeBetweenUploads));
    }
    return null;
  }