Skip to content

Commit 09a5468

Browse files
author
Steve Martinelli
committed
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
1 parent 505c784 commit 09a5468

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

openstackclient/object/v1/lib/object.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
"""Object v1 API library"""
1818

19+
import os
20+
1921
import six
2022

2123
try:
@@ -171,6 +173,8 @@ def save_object(
171173

172174
response = session.get("%s/%s/%s" % (url, container, obj), stream=True)
173175
if response.status_code == 200:
176+
if not os.path.exists(os.path.dirname(file)):
177+
os.makedirs(os.path.dirname(file))
174178
with open(file, 'wb') as f:
175179
for chunk in response.iter_content():
176180
f.write(chunk)

0 commit comments

Comments
 (0)