From baba8fa92f47cad604f6d2a2714d09f89178fbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Mon, 30 Apr 2018 23:35:10 +0200 Subject: Upgrading minio-go library to 6.0.0 (#8651) * Upgrading minio-go library to 6.0.0 * Removing unnecesary Gopkg constraint --- utils/file_backend_s3.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'utils/file_backend_s3.go') diff --git a/utils/file_backend_s3.go b/utils/file_backend_s3.go index 2f644f602..87ed3dd16 100644 --- a/utils/file_backend_s3.go +++ b/utils/file_backend_s3.go @@ -13,6 +13,7 @@ import ( s3 "github.com/minio/minio-go" "github.com/minio/minio-go/pkg/credentials" + "github.com/minio/minio-go/pkg/encrypt" "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" @@ -105,7 +106,7 @@ func (b *S3FileBackend) CopyFile(oldPath, newPath string) *model.AppError { } source := s3.NewSourceInfo(b.bucket, oldPath, nil) - destination, err := s3.NewDestinationInfo(b.bucket, newPath, nil, s3CopyMetadata(b.encrypt)) + destination, err := s3.NewDestinationInfo(b.bucket, newPath, encrypt.NewSSE(), nil) if err != nil { return model.NewAppError("copyFile", "api.file.write_file.s3.app_error", nil, err.Error(), http.StatusInternalServerError) } @@ -122,7 +123,7 @@ func (b *S3FileBackend) MoveFile(oldPath, newPath string) *model.AppError { } source := s3.NewSourceInfo(b.bucket, oldPath, nil) - destination, err := s3.NewDestinationInfo(b.bucket, newPath, nil, s3CopyMetadata(b.encrypt)) + destination, err := s3.NewDestinationInfo(b.bucket, newPath, encrypt.NewSSE(), nil) if err != nil { return model.NewAppError("moveFile", "api.file.write_file.s3.app_error", nil, err.Error(), http.StatusInternalServerError) } @@ -231,23 +232,16 @@ func (b *S3FileBackend) RemoveDirectory(path string) *model.AppError { return nil } -func s3PutOptions(encrypt bool, contentType string) s3.PutObjectOptions { +func s3PutOptions(encrypted bool, contentType string) s3.PutObjectOptions { options := s3.PutObjectOptions{} - if encrypt { - options.UserMetadata = make(map[string]string) - options.UserMetadata["x-amz-server-side-encryption"] = "AES256" + if encrypted { + options.ServerSideEncryption = encrypt.NewSSE() } options.ContentType = contentType return options } -func s3CopyMetadata(encrypt bool) map[string]string { - metaData := make(map[string]string) - metaData["x-amz-server-side-encryption"] = "AES256" - return metaData -} - func CheckMandatoryS3Fields(settings *model.FileSettings) *model.AppError { if len(settings.AmazonS3Bucket) == 0 { return model.NewAppError("S3File", "api.admin.test_s3.missing_s3_bucket", nil, "", http.StatusBadRequest) -- cgit v1.2.3-1-g7c22