def get_file_size(fp):
    """Get size of the file or length of a bytes object"""
    fp.seek(0, 2)  # move the current position to the end of the file
    size = fp.tell()
    fp.seek(0, 0)  # move the current position to the beginning of the file
    return size