mirror of
https://github.com/wassname/flask-s3.git
synced 2026-08-01 12:30:46 +08:00
Work around BucketAlreadyOwnedByYou
Buckets outside of the standard region will raise an error if you try create them and they already exist. See: https://forums.aws.amazon.com/thread.jspa?threadID=119095
This commit is contained in:
+8
-1
@@ -184,7 +184,14 @@ 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)
|
||||
try:
|
||||
bucket = conn.create_bucket(bucket_name, location=location)
|
||||
except S3CreateError as e:
|
||||
if e.error_code == u'BucketAlreadyOwnedByYou':
|
||||
bucket = conn.get_bucket(bucket_name)
|
||||
else:
|
||||
raise e
|
||||
|
||||
bucket.make_public(recursive=True)
|
||||
except S3CreateError as e:
|
||||
raise e
|
||||
|
||||
Reference in New Issue
Block a user