diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 1298b227..ee467784 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -799,11 +799,18 @@ func (c *s3Client) MakeBucket(region string, ignoreExisting bool) *probe.Error { if bucket == "" { return probe.NewError(BucketNameEmpty{}) } - if object != "" { if strings.HasSuffix(object, "/") { - _, e := c.api.PutObject(bucket, object, bytes.NewReader([]byte("")), 0, minio.PutObjectOptions{}) - if e != nil { + retry: + if _, e := c.api.PutObject(bucket, object, bytes.NewReader([]byte("")), 0, minio.PutObjectOptions{}); e != nil { + switch minio.ToErrorResponse(e).Code { + case "NoSuchBucket": + e = c.api.MakeBucket(bucket, region) + if e != nil { + return probe.NewError(e) + } + goto retry + } return probe.NewError(e) } return nil