mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Vendorize new changes from minio-go repo (#5821)
- When policy is empty delete the bucket policy (#966) (04/13/18) <Harshavardhana> - Add tests to check if ListObjects/V2 returns expected StorageClass (#963) (04/10/18) <Nitish Tiwari> - Update get/setBucketPolicy methods to use files instead of pkg/policy (#959) (04/10/18) <Nitish Tiwari> - avoid unnecessary stat call during single copy (#962) (04/06/18) <Andreas Auernhammer> - avoid sending SSE-S3 header during GET requests. (#965) (04/05/18) <Andreas Auernhammer> - Fix stream SSE uploads with S3 encrypt type (#960) (04/02/18) <Jesús Espino> - Fix xml parsing error for RemoveObjects API (#949) (03/29/18) <poornas> - Allow to upload empty files in stream based uploads (#958) (03/26/18) <Jesús Espino> - Add missing doneCh in the example for removeobjects (#955) (03/26/18) <Alexandr Korsak> - tests: Remove partial related tests (#957) (03/26/18) <Anis Elleuch> - Add transport connection broken error to retry list (#956) (03/19/18) <poornas> - [refactor]: simplify client encryption examples (#952) (03/19/18) <Andreas Auernhammer> - Add tests for putObjectContentLanguage (#950) (03/15/18) <Harshavardhana> - Add putObject/getObject() client side encryption examples (#948) (03/13/18) <Harshavardhana>
This commit is contained in:
committed by
Nitish Tiwari
parent
638f01f9e4
commit
97a8d856b6
@@ -18,6 +18,7 @@ package s3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
"github.com/minio/cli"
|
||||
@@ -428,7 +429,11 @@ func (l *s3Objects) CompleteMultipartUpload(ctx context.Context, bucket string,
|
||||
|
||||
// SetBucketPolicy sets policy on bucket
|
||||
func (l *s3Objects) SetBucketPolicy(ctx context.Context, bucket string, policyInfo policy.BucketAccessPolicy) error {
|
||||
if err := l.Client.PutBucketPolicy(bucket, policyInfo); err != nil {
|
||||
data, err := json.Marshal(&policyInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := l.Client.SetBucketPolicy(bucket, string(data)); err != nil {
|
||||
logger.LogIf(ctx, err)
|
||||
return minio.ErrorRespToObjectError(err, bucket, "")
|
||||
}
|
||||
@@ -438,17 +443,21 @@ func (l *s3Objects) SetBucketPolicy(ctx context.Context, bucket string, policyIn
|
||||
|
||||
// GetBucketPolicy will get policy on bucket
|
||||
func (l *s3Objects) GetBucketPolicy(ctx context.Context, bucket string) (policy.BucketAccessPolicy, error) {
|
||||
policyInfo, err := l.Client.GetBucketPolicy(bucket)
|
||||
data, err := l.Client.GetBucketPolicy(bucket)
|
||||
if err != nil {
|
||||
logger.LogIf(ctx, err)
|
||||
return policy.BucketAccessPolicy{}, minio.ErrorRespToObjectError(err, bucket, "")
|
||||
}
|
||||
var policyInfo policy.BucketAccessPolicy
|
||||
if err = json.Unmarshal([]byte(data), &policyInfo); err != nil {
|
||||
return policyInfo, err
|
||||
}
|
||||
return policyInfo, nil
|
||||
}
|
||||
|
||||
// DeleteBucketPolicy deletes all policies on bucket
|
||||
func (l *s3Objects) DeleteBucketPolicy(ctx context.Context, bucket string) error {
|
||||
if err := l.Client.PutBucketPolicy(bucket, policy.BucketAccessPolicy{}); err != nil {
|
||||
if err := l.Client.SetBucketPolicy(bucket, ""); err != nil {
|
||||
logger.LogIf(ctx, err)
|
||||
return minio.ErrorRespToObjectError(err, bucket, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user