def METHOD_NAME(filename, hash_fn=hashlib.sha1, block_size=4096):
    """
    Calculate the hash of the contents of a given file path.
    :type filename: str or Path
    :param block_size: Number of bytes to read at a time. (for performance: doesn't affect result)
    :param hash_fn: hashlib function to use. (typically sha1 or md5)
    :return: String of hex characters.
    :rtype: str
    """
    if is_s3_uri(str(filename)):
        bucket, key = get_bucket_key(filename)
        try:
            region_name = os.environ["AWS_DEFAULT_REGION"]
        except Exception as exp:
            raise ValueError(
                "Failed to find AWS_DEFAULT_REGION in the environment variables"
            ) from exp
        s3client = boto3.client("s3", region_name=region_name)
        fileobj = s3client.get_object(Bucket=bucket, Key=key)
        f = fileobj["Body"].read()
        return calculate_hash(f, hash_fn, block_size)
    else:
        with Path(filename).open("rb") as f:
            return calculate_hash(f, hash_fn, block_size)