import base64


def decode_attachment_data(attachment) -> bytes:
    """
    Decode a raw attachment into usable bytes.

    :param attachment:
    :return: the bytes containing file data
    """
    if attachment['content_transfer_encoding'] == 'base64':
        return base64.b64decode(attachment['payload'])
    return attachment['payload'].encode('utf-8')