import io
import os
with open('test.xlsx', 'rb') as f:
    g = io.BytesIO(f.read())
temporarylocation = 'testout.xlsx'
with open(temporarylocation, 'wb') as out:
    out.write(g.read())
os.remove(temporarylocation)
Convert BytesIO into File