import io


def get_files_from_doc(doc):
    """
    Load all attachments from a couch doc into a readable object
    """

    files = {}
    for f in doc._attachments.keys():
        if f[-4:].lower() != '.xml':
            # we really only want images/videos, but specifically
            # blacklisting uploaded config files
            files[f] = io.BytesIO(doc.fetch_attachment(f))

    return files