def get_size(file_object):
    """Get the file size of a file uploaded through a form.

    Args:
        file_object (object): A file from the `files` part of a POST request.


    Returns:
        int: File size in bytes.
    """
    if file_object.content_length:
        return file_object.content_length

    try:
        pos = file_object.tell()
        file_object.seek(0, 2)  # Seek to end
        size = file_object.tell()
        file_object.seek(pos)  # Back to original position
        return size
    except (AttributeError, IOError):
        pass

    # in-memory file object that doesn't support seeking or tell
    return 0