forked from TrueCloudLab/frostfs-s3-gw
Merge pull request #143 from KirillovDenis/bugfix/125-check_bucket_unique
[#125] Fixed bucket creation
This commit is contained in:
commit
7b1058a9bd
4 changed files with 125 additions and 15 deletions
|
@ -20,6 +20,8 @@ const (
|
|||
basicACLReadOnly = "public-read"
|
||||
basicACLPublic = "public-read-write"
|
||||
defaultPolicy = "REP 3"
|
||||
|
||||
publicBasicRule = 0x0FFFFFFF
|
||||
)
|
||||
|
||||
func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -99,7 +101,7 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if val, ok := r.Header["X-Amz-Acl"]; ok {
|
||||
p.ACL, err = parseBasicACL(val[0])
|
||||
} else {
|
||||
p.ACL = acl.PrivateBasicRule
|
||||
p.ACL = publicBasicRule
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -112,6 +114,7 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
|
|||
Description: err.Error(),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}, r.URL)
|
||||
return
|
||||
}
|
||||
|
||||
p.Policy, err = policy.Parse(defaultPolicy)
|
||||
|
@ -125,6 +128,7 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
|
|||
Description: err.Error(),
|
||||
HTTPStatusCode: http.StatusBadRequest,
|
||||
}, r.URL)
|
||||
return
|
||||
}
|
||||
|
||||
cid, err := h.obj.CreateBucket(r.Context(), &p)
|
||||
|
@ -138,6 +142,7 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
|
|||
Description: err.Error(),
|
||||
HTTPStatusCode: http.StatusInternalServerError,
|
||||
}, r.URL)
|
||||
return
|
||||
}
|
||||
|
||||
h.log.Info("bucket is created",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue