How do I get the binary representation of a tarfile
object in Python? Right now I am doing the following, but this involves "copying":
with BytesIO() as out_buffer:
with tarfile.open(fileobj=out_buffer, mode='w') as newtar:
for member in data:
newtar.addfile(member, data.extractfile(member))
tar_binary = out_buffer.getvalue()