def base64_encodefile(fname):
    encoded_f = StringIO.StringIO()

    with open(fname, 'rb') as f:
        base64.encode(f, encoded_f)

    encoded_f.seek(0)
    return encoded_f.read()
Read a file from the file system and return as a base64 encoded string
dataset/ETHPy150Open saltstack/salt/salt/modules/hashutil.py/base64_encodefile