  def CheckForObject(
      self,
      bucket: str,
      key: str
    ) -> bool:
    """Check if an object exists in S3.

    Args:
      bucket (str): S3 bucket name.
      key (str): object path and name.

    Returns:
      bool: True if the object exists and you have permissions to GetObject.
        False otherwise."""
    s3_client = self.aws_account.ClientApi(common.S3_SERVICE)

    if key.startswith('/'):
      key = key.lstrip('/')

    try:
      s3_client.head_object(Bucket=bucket, Key=key)
    except s3_client.exceptions.ClientError:
      return False
    return True
Check if an object exists in S3.

Args:
bucket (str): S3 bucket name.
key (str): object path and name.

Returns:
bool: True if the object exists and you have permissions to GetObject.
False otherwise.
libcloudforensics/providers/aws/internal/s3.py