From f02620b291b988848392c455a7719699f6b5c00f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 26 Oct 2016 05:21:07 -0700 Subject: Moving away from goamz to use minio-go instead. (#4193) minio-go does fully managed way of handling S3 API requests - Automatic bucket location management across all s3 regions. - Transparently upload large files in multipart if file 64MB or larger. - Right GetObject() API provides compatibility with io.ReadWriteSeeker interface. - Various other APIs including bulk deletes, server side object copy, bucket policies and bucket notifications. Fixes #4182 --- api/file_test.go | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'api/file_test.go') diff --git a/api/file_test.go b/api/file_test.go index ded866ab6..5d440f112 100644 --- a/api/file_test.go +++ b/api/file_test.go @@ -6,11 +6,6 @@ package api import ( "bytes" "fmt" - "github.com/goamz/goamz/aws" - "github.com/goamz/goamz/s3" - "github.com/mattermost/platform/model" - "github.com/mattermost/platform/store" - "github.com/mattermost/platform/utils" "io" "io/ioutil" "net/http" @@ -18,6 +13,12 @@ import ( "strings" "testing" "time" + + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/store" + "github.com/mattermost/platform/utils" + + s3 "github.com/minio/minio-go" ) func TestUploadFile(t *testing.T) { @@ -830,25 +831,27 @@ func readTestFile(name string) ([]byte, error) { func cleanupTestFile(info *model.FileInfo) error { if utils.Cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 { - var auth aws.Auth - auth.AccessKey = utils.Cfg.FileSettings.AmazonS3AccessKeyId - auth.SecretKey = utils.Cfg.FileSettings.AmazonS3SecretAccessKey - - s := s3.New(auth, aws.Regions[utils.Cfg.FileSettings.AmazonS3Region]) - bucket := s.Bucket(utils.Cfg.FileSettings.AmazonS3Bucket) - - if err := bucket.Del(info.Path); err != nil { + endpoint := utils.Cfg.FileSettings.AmazonS3Endpoint + accessKey := utils.Cfg.FileSettings.AmazonS3AccessKeyId + secretKey := utils.Cfg.FileSettings.AmazonS3SecretAccessKey + secure := *utils.Cfg.FileSettings.AmazonS3SSL + s3Clnt, err := s3.New(endpoint, accessKey, secretKey, secure) + if err != nil { + return err + } + bucket := utils.Cfg.FileSettings.AmazonS3Bucket + if err := s3Clnt.RemoveObject(bucket, info.Path); err != nil { return err } if info.ThumbnailPath != "" { - if err := bucket.Del(info.ThumbnailPath); err != nil { + if err := s3Clnt.RemoveObject(bucket, info.ThumbnailPath); err != nil { return err } } if info.PreviewPath != "" { - if err := bucket.Del(info.PreviewPath); err != nil { + if err := s3Clnt.RemoveObject(bucket, info.PreviewPath); err != nil { return err } } -- cgit v1.2.3-1-g7c22