forked from TrueCloudLab/frostfs-s3-gw
parent
ccf5db95a5
commit
7d0bc1e992
12 changed files with 434 additions and 25 deletions
42
api/layer/cors.go
Normal file
42
api/layer/cors.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package layer
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
||||
"github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
||||
)
|
||||
|
||||
func (n *layer) PutBucketCORS(ctx context.Context, p *PutCORSParams) error {
|
||||
s := &PutSystemObjectParams{
|
||||
BktInfo: p.BktInfo,
|
||||
ObjName: p.BktInfo.CORSObjectName(),
|
||||
Metadata: map[string]string{},
|
||||
Prefix: "",
|
||||
Payload: p.CORSConfiguration,
|
||||
}
|
||||
|
||||
_, err := n.putSystemObject(ctx, s)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (n *layer) GetBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) ([]byte, error) {
|
||||
obj, err := n.getSystemObject(ctx, bktInfo, bktInfo.CORSObjectName())
|
||||
if err != nil {
|
||||
if errors.IsS3Error(err, errors.ErrNoSuchKey) {
|
||||
return nil, errors.GetAPIError(errors.ErrNoSuchCORSConfiguration)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if obj.Payload() == nil {
|
||||
return nil, errors.GetAPIError(errors.ErrInternalError)
|
||||
}
|
||||
|
||||
return obj.Payload(), nil
|
||||
}
|
||||
|
||||
func (n *layer) DeleteBucketCORS(ctx context.Context, bktInfo *data.BucketInfo) error {
|
||||
return n.deleteSystemObject(ctx, bktInfo, bktInfo.CORSObjectName())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue