fix error when trying to re-create media folder

This commit is contained in:
James Ravenscroft 2021-12-24 10:50:40 +00:00
parent e7ae240555
commit c7ea1bc1c8
1 changed files with 2 additions and 1 deletions

View File

@ -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)