Created
June 5, 2015 18:15
-
-
Save vsudilov/cc25a6eee101a375bfed to your computer and use it in GitHub Desktop.
in-memory tarfile with in-memory contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tar_fileobj = io.BytesIO() | |
with tarfile.open(fileobj=tar_fileobj, mode="w|") as tar: | |
my_content = "abdef".encode('utf-8') | |
tf = tarfile.TarInfo("my_file_name") | |
tf.size = len(my_content) | |
tar.addfile(tf, io.BytesIO(my_content)) | |
tar_fileobj.seek(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!