summaryrefslogtreecommitdiffstats
path: root/api/file_test.go
diff options
context:
space:
mode:
authorHarshavardhana <harsha@minio.io>2016-10-26 05:21:07 -0700
committerChristopher Speller <crspeller@gmail.com>2016-10-26 08:21:07 -0400
commitf02620b291b988848392c455a7719699f6b5c00f (patch)
tree695e07607e86b000b9fe78e77df7f33673f1a755 /api/file_test.go
parentb354d25d3731b53613489d95cfa4c946cf8e0888 (diff)
downloadchat-f02620b291b988848392c455a7719699f6b5c00f.tar.gz
chat-f02620b291b988848392c455a7719699f6b5c00f.tar.bz2
chat-f02620b291b988848392c455a7719699f6b5c00f.zip
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
Diffstat (limited to 'api/file_test.go')
-rw-r--r--api/file_test.go33
1 files changed, 18 insertions, 15 deletions
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
}
}