Add support for 'file' format objects
Some objects can be saved as 'dirname/filename' which causes the existing support to fail. The correct behaviour should be to create the directories needed. Change-Id: I71c61bc3b0f76a3e6d2703bd45508f9d6483546e
This commit is contained in:
parent
505c784bad
commit
09a546891f
@ -16,6 +16,8 @@
|
||||
|
||||
"""Object v1 API library"""
|
||||
|
||||
import os
|
||||
|
||||
import six
|
||||
|
||||
try:
|
||||
@ -171,6 +173,8 @@ def save_object(
|
||||
|
||||
response = session.get("%s/%s/%s" % (url, container, obj), stream=True)
|
||||
if response.status_code == 200:
|
||||
if not os.path.exists(os.path.dirname(file)):
|
||||
os.makedirs(os.path.dirname(file))
|
||||
with open(file, 'wb') as f:
|
||||
for chunk in response.iter_content():
|
||||
f.write(chunk)
|
||||
|
Loading…
x
Reference in New Issue
Block a user