No need to over complicate. `tempfile.SpooledTemporaryFile()` to the rescue.