Allow passing in file objects to add_file()

This commit is contained in:
Kovid Goyal 2016-10-09 14:57:09 +05:30
parent 1255f81cfd
commit 7bf79bd650

View File

@ -335,6 +335,9 @@ class Container(ContainerBase): # {{{
if not os.path.exists(base):
os.makedirs(base)
with lopen(path, 'wb') as f:
if hasattr(data, 'read'):
shutil.copyfileobj(data, f)
else:
f.write(data)
mt = media_type or self.guess_type(name)
self.name_path_map[name] = path