Skip to content

Commit

Permalink
Merge pull request #362 from harshavardhana/make-bucket
Browse files Browse the repository at this point in the history
make_bucket: Make bucket should be done only as path style.
  • Loading branch information
Harshavardhana committed Jan 25, 2016
2 parents f9b54dd + 5447c15 commit fa05ebd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,14 @@ def make_bucket(self, bucket_name, location='us-east-1', acl=None):
content_md5_base64 = encode_to_base64(get_md5(content))
headers['Content-MD5'] = content_md5_base64

# In case of Amazon S3. The make bucket issued on already
# existing bucket would fail with 'AuthorizationMalformed'
# error if virtual style is used. So we default to 'path
# style' as that is the preferred method here. The final
# location of the 'bucket' is provided through XML
# LocationConstraint data with the request.
# Construct target url.
url = get_target_url(self._endpoint_url,
bucket_name=bucket_name)
url = self._endpoint_url + '/' + bucket_name + '/'

# Get signature headers if any.
headers = sign_v4(method, url, 'us-east-1',
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ def main():
print(client.make_bucket(bucket_name+'.unique',
location='us-west-1'))

## Check if return codes a valid from server.
try:
client.make_bucket(bucket_name+'.unique',
location='us-west-1')
except ResponseError as err:
if str(err.code) in ['BucketAlreadyOwnedByYou', 'BucketAlreadyExists']:
pass
else:
raise

# Check if bucket was created properly.
print(client.bucket_exists(bucket_name))
print(client.bucket_exists(bucket_name+'.unique'))
Expand Down

0 comments on commit fa05ebd

Please sign in to comment.