diff --git a/example.py b/example.py index 5efc94c..0ef06d4 100644 --- a/example.py +++ b/example.py @@ -118,7 +118,8 @@ def req(): photo_url = os.path.join(os.environ.get('MICROPUB_MEDIA_URL_PREFIX'), now.strftime("%Y/%m/%d"), str(now_ts) + ".jpg") # make directory if needed - os.makedirs(os.path.dirname(filename)) + if not os.path.exists(os.path.dirname(filename)): + os.makedirs(os.path.dirname(filename)) with open(filename, 'wb') as f: f.write(r.content)