Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions flask_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from flask import url_for as flask_url_for
from flask import current_app
from boto.s3.connection import S3Connection
from boto.exception import S3CreateError
from boto.exception import S3ResponseError
from boto.s3.key import Key

logger = logging.getLogger('flask_s3')
Expand Down Expand Up @@ -184,10 +184,13 @@ def create_all(app, user=None, password=None, bucket_name=None,
conn = S3Connection(user, password) # connect to s3
# get_or_create bucket
try:
bucket = conn.create_bucket(bucket_name, location=location)
bucket.make_public(recursive=True)
except S3CreateError as e:
raise e
bucket = conn.get_bucket(bucket_name)
except S3ResponseError as e:
if '404 Not Found' in str(e):
bucket = conn.create_bucket(bucket_name, location=location)
else:
raise
bucket.make_public(recursive=True)
_upload_files(app, all_files, bucket)


Expand Down